Spaces:
Running
Running
Update webscout.py
Browse files- webscout.py +14 -0
webscout.py
CHANGED
@@ -1709,3 +1709,17 @@ class LLM:
|
|
1709 |
return result.json()['choices'][0]['message']['content']
|
1710 |
except:
|
1711 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1709 |
return result.json()['choices'][0]['message']['content']
|
1710 |
except:
|
1711 |
return None
|
1712 |
+
def fastai(user, model="llama3-70b", system="Answer as concisely as possible."):
|
1713 |
+
env_type = "tp16405b" if "405b" in model else "tp16"
|
1714 |
+
data = {'body': {'messages': [{'role': 'system', 'content': system}, {'role': 'user', 'content': user}], 'stream': True, 'model': model}, 'env_type': env_type}
|
1715 |
+
with requests.post('https://fast.snova.ai/api/completion', headers={'content-type': 'application/json'}, json=data, stream=True) as response:
|
1716 |
+
output = ''
|
1717 |
+
for line in response.iter_lines(decode_unicode=True):
|
1718 |
+
if line.startswith('data:'):
|
1719 |
+
try:
|
1720 |
+
data = json.loads(line[len('data: '):])
|
1721 |
+
output += data.get("choices", [{}])[0].get("delta", {}).get("content", '')
|
1722 |
+
except json.JSONDecodeError:
|
1723 |
+
if line[len('data: '):] == '[DONE]':
|
1724 |
+
break
|
1725 |
+
return output
|