Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- src/builder_llm.py +1 -1
- src/observer_llm.py +9 -26
src/builder_llm.py
CHANGED
|
@@ -57,7 +57,7 @@ def call_hf_inference(prompt: str) -> str:
|
|
| 57 |
|
| 58 |
token = os.getenv("HF_TOKEN") or os.getenv("HUGGING_FACE_HUB_TOKEN")
|
| 59 |
client = InferenceClient(token=token)
|
| 60 |
-
model = os.getenv("HF_TEXT_MODEL", "
|
| 61 |
response = client.chat_completion(
|
| 62 |
model=model,
|
| 63 |
messages=[{"role": "user", "content": prompt}],
|
|
|
|
| 57 |
|
| 58 |
token = os.getenv("HF_TOKEN") or os.getenv("HUGGING_FACE_HUB_TOKEN")
|
| 59 |
client = InferenceClient(token=token)
|
| 60 |
+
model = os.getenv("HF_TEXT_MODEL", "Qwen/Qwen2.5-7B-Instruct")
|
| 61 |
response = client.chat_completion(
|
| 62 |
model=model,
|
| 63 |
messages=[{"role": "user", "content": prompt}],
|
src/observer_llm.py
CHANGED
|
@@ -63,37 +63,20 @@ def call_openai(prompt: str, frame_b64: str | None = None) -> str:
|
|
| 63 |
def call_hf_inference(prompt: str, frame_b64: str | None = None) -> str:
|
| 64 |
"""Call HF Inference API using huggingface_hub InferenceClient.
|
| 65 |
|
| 66 |
-
Uses
|
| 67 |
-
|
| 68 |
"""
|
| 69 |
from huggingface_hub import InferenceClient
|
| 70 |
|
| 71 |
token = os.getenv("HF_TOKEN") or os.getenv("HUGGING_FACE_HUB_TOKEN")
|
| 72 |
client = InferenceClient(token=token)
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
model
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
"role": "user",
|
| 81 |
-
"content": [
|
| 82 |
-
{"type": "text", "text": prompt},
|
| 83 |
-
{"type": "image_url", "image_url": {"url": image_url}},
|
| 84 |
-
],
|
| 85 |
-
}],
|
| 86 |
-
max_tokens=800,
|
| 87 |
-
)
|
| 88 |
-
return response.choices[0].message.content
|
| 89 |
-
else:
|
| 90 |
-
model = os.getenv("HF_TEXT_MODEL", "meta-llama/Llama-3.1-8B-Instruct")
|
| 91 |
-
response = client.chat_completion(
|
| 92 |
-
model=model,
|
| 93 |
-
messages=[{"role": "user", "content": prompt}],
|
| 94 |
-
max_tokens=800,
|
| 95 |
-
)
|
| 96 |
-
return response.choices[0].message.content
|
| 97 |
|
| 98 |
|
| 99 |
def observe(state: SessionState, compact_state: dict) -> dict:
|
|
|
|
| 63 |
def call_hf_inference(prompt: str, frame_b64: str | None = None) -> str:
|
| 64 |
"""Call HF Inference API using huggingface_hub InferenceClient.
|
| 65 |
|
| 66 |
+
Uses text model with compressed sensory state as text input.
|
| 67 |
+
Vision encoding (entropy, motion, phash) is already done by vision_sampler.
|
| 68 |
"""
|
| 69 |
from huggingface_hub import InferenceClient
|
| 70 |
|
| 71 |
token = os.getenv("HF_TOKEN") or os.getenv("HUGGING_FACE_HUB_TOKEN")
|
| 72 |
client = InferenceClient(token=token)
|
| 73 |
+
model = os.getenv("HF_TEXT_MODEL", "Qwen/Qwen2.5-7B-Instruct")
|
| 74 |
+
response = client.chat_completion(
|
| 75 |
+
model=model,
|
| 76 |
+
messages=[{"role": "user", "content": prompt}],
|
| 77 |
+
max_tokens=800,
|
| 78 |
+
)
|
| 79 |
+
return response.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
|
| 82 |
def observe(state: SessionState, compact_state: dict) -> dict:
|