Spaces:
Running
Running
Use environment variables for selecting the models.
Browse files
examples/Graph RAG
CHANGED
|
@@ -510,8 +510,7 @@
|
|
| 510 |
"title": "Ask LLM",
|
| 511 |
"params": {
|
| 512 |
"max_tokens": 100.0,
|
| 513 |
-
"accepted_regex": ""
|
| 514 |
-
"model": "SultanR/SmolTulu-1.7b-Instruct"
|
| 515 |
},
|
| 516 |
"display": null,
|
| 517 |
"error": null,
|
|
@@ -541,13 +540,6 @@
|
|
| 541 |
"type": {
|
| 542 |
"type": "<class 'int'>"
|
| 543 |
}
|
| 544 |
-
},
|
| 545 |
-
"model": {
|
| 546 |
-
"type": {
|
| 547 |
-
"type": "<class 'str'>"
|
| 548 |
-
},
|
| 549 |
-
"default": null,
|
| 550 |
-
"name": "model"
|
| 551 |
}
|
| 552 |
},
|
| 553 |
"outputs": {
|
|
|
|
| 510 |
"title": "Ask LLM",
|
| 511 |
"params": {
|
| 512 |
"max_tokens": 100.0,
|
| 513 |
+
"accepted_regex": ""
|
|
|
|
| 514 |
},
|
| 515 |
"display": null,
|
| 516 |
"error": null,
|
|
|
|
| 540 |
"type": {
|
| 541 |
"type": "<class 'int'>"
|
| 542 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 543 |
}
|
| 544 |
},
|
| 545 |
"outputs": {
|
lynxkite-lynxscribe/README.md
CHANGED
|
@@ -23,5 +23,9 @@ uv pip install infinity-emb[all]
|
|
| 23 |
infinity_emb v2 --model-id michaelfeil/bge-small-en-v1.5
|
| 24 |
uv pip install "sglang[all]>=0.4.2.post2" --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer/
|
| 25 |
python -m sglang.launch_server --model-path SultanR/SmolTulu-1.7b-Instruct --port 8080
|
| 26 |
-
LLM_BASE_URL='http://localhost:8080/v1'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
```
|
|
|
|
| 23 |
infinity_emb v2 --model-id michaelfeil/bge-small-en-v1.5
|
| 24 |
uv pip install "sglang[all]>=0.4.2.post2" --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer/
|
| 25 |
python -m sglang.launch_server --model-path SultanR/SmolTulu-1.7b-Instruct --port 8080
|
| 26 |
+
export LLM_BASE_URL='http://localhost:8080/v1'
|
| 27 |
+
export LLM_MODEL='SultanR/SmolTulu-1.7b-Instruct'
|
| 28 |
+
export EMBEDDING_BASE_URL='http://localhost:7997/'
|
| 29 |
+
export EMBEDDING_MODEL='michaelfeil/bge-small-en-v1.5'
|
| 30 |
+
lynxkite
|
| 31 |
```
|
lynxkite-lynxscribe/src/lynxkite_lynxscribe/llm_ops.py
CHANGED
|
@@ -130,8 +130,7 @@ def create_prompt(input, *, save_as="prompt", template: ops.LongStr):
|
|
| 130 |
|
| 131 |
|
| 132 |
@op("Ask LLM")
|
| 133 |
-
def ask_llm(input, *,
|
| 134 |
-
assert model, "Please specify the model."
|
| 135 |
assert "prompt" in input, "Please create the prompt first."
|
| 136 |
options = {}
|
| 137 |
if accepted_regex:
|
|
@@ -139,7 +138,6 @@ def ask_llm(input, *, model: str, accepted_regex: str = None, max_tokens: int =
|
|
| 139 |
"regex": accepted_regex,
|
| 140 |
}
|
| 141 |
results = chat(
|
| 142 |
-
model=model,
|
| 143 |
max_tokens=max_tokens,
|
| 144 |
messages=[
|
| 145 |
{"role": "user", "content": input["prompt"]},
|
|
@@ -228,10 +226,9 @@ def rag(
|
|
| 228 |
results = [db[int(r)] for r in results["ids"][0]]
|
| 229 |
return {**input, "rag": results, "_collection": collection}
|
| 230 |
if engine == RagEngine.Custom:
|
| 231 |
-
model = "michaelfeil/bge-small-en-v1.5"
|
| 232 |
chat = input[input_field]
|
| 233 |
-
embeddings = [embedding(input=[r[db_field]]
|
| 234 |
-
q = embedding(input=[chat]
|
| 235 |
|
| 236 |
def cosine_similarity(a, b):
|
| 237 |
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
@op("Ask LLM")
|
| 133 |
+
def ask_llm(input, *, accepted_regex: str = None, max_tokens: int = 100):
|
|
|
|
| 134 |
assert "prompt" in input, "Please create the prompt first."
|
| 135 |
options = {}
|
| 136 |
if accepted_regex:
|
|
|
|
| 138 |
"regex": accepted_regex,
|
| 139 |
}
|
| 140 |
results = chat(
|
|
|
|
| 141 |
max_tokens=max_tokens,
|
| 142 |
messages=[
|
| 143 |
{"role": "user", "content": input["prompt"]},
|
|
|
|
| 226 |
results = [db[int(r)] for r in results["ids"][0]]
|
| 227 |
return {**input, "rag": results, "_collection": collection}
|
| 228 |
if engine == RagEngine.Custom:
|
|
|
|
| 229 |
chat = input[input_field]
|
| 230 |
+
embeddings = [embedding(input=[r[db_field]]) for r in db]
|
| 231 |
+
q = embedding(input=[chat])
|
| 232 |
|
| 233 |
def cosine_similarity(a, b):
|
| 234 |
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
|