-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathallm.py
More file actions
29 lines (25 loc) · 858 Bytes
/
allm.py
File metadata and controls
29 lines (25 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
API_URL = "http://localhost:3001/api/v1/query"
API_TOKEN = "YERSFS8-8XRMTCA-K5MD0CR-F3ABYNH" # Replace this
WORKSPACE_ID = "SnapSign" # Replace this
def clean_isl_text(raw_text: str) -> str:
"""
Sends raw ISL-detected text to AnythingLLM and returns the cleaned sentence.
"""
headers = {
"Authorization": f"Bearer {API_TOKEN}"
}
payload = {
"message": raw_text,
"workspace_id": WORKSPACE_ID,
"system_prompt": "TextCleaner",
"temperature": 0.0,
"max_tokens": 60
}
try:
response = requests.post(API_URL, json=payload, headers=headers, timeout=2)
response.raise_for_status()
return response.json()["response"].strip()
except Exception as e:
print(f"[LLM Error] {e}")
return raw_text.capitalize() # Fallback