Spaces:
Runtime error
Runtime error
Update example.py
Browse files- example.py +14 -9
example.py
CHANGED
|
@@ -11,7 +11,8 @@ import json
|
|
| 11 |
import os
|
| 12 |
import warnings
|
| 13 |
from dotenv import load_dotenv
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
warnings.filterwarnings("ignore")
|
| 17 |
load_dotenv()
|
|
@@ -24,7 +25,9 @@ USERS_FILE = 'users_data.json'
|
|
| 24 |
|
| 25 |
# Together API for chatbot
|
| 26 |
TOGETHER_API_KEY = os.getenv("TOGETHER_API_KEY")
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Assessment Questions
|
| 30 |
QUESTIONS = [
|
|
@@ -324,14 +327,16 @@ Rules: Keep 30-50 words, be respectful, use * for bullet points (format: "Text:
|
|
| 324 |
|
| 325 |
try:
|
| 326 |
# Call Together API with limited tokens for concise responses
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
|
|
|
| 333 |
|
| 334 |
-
bot_response = response.
|
|
|
|
| 335 |
|
| 336 |
return jsonify({
|
| 337 |
"success": True,
|
|
|
|
| 11 |
import os
|
| 12 |
import warnings
|
| 13 |
from dotenv import load_dotenv
|
| 14 |
+
import together
|
| 15 |
+
|
| 16 |
|
| 17 |
warnings.filterwarnings("ignore")
|
| 18 |
load_dotenv()
|
|
|
|
| 25 |
|
| 26 |
# Together API for chatbot
|
| 27 |
TOGETHER_API_KEY = os.getenv("TOGETHER_API_KEY")
|
| 28 |
+
together.api_key = TOGETHER_API_KEY
|
| 29 |
+
client = together if TOGETHER_API_KEY else None
|
| 30 |
+
|
| 31 |
|
| 32 |
# Assessment Questions
|
| 33 |
QUESTIONS = [
|
|
|
|
| 327 |
|
| 328 |
try:
|
| 329 |
# Call Together API with limited tokens for concise responses
|
| 330 |
+
response = together.chat.completions.create(
|
| 331 |
+
model="meta-llama/Meta-Llama-3-8B-Instruct-Lite",
|
| 332 |
+
messages=messages,
|
| 333 |
+
max_tokens=80,
|
| 334 |
+
temperature=0.7,
|
| 335 |
+
)
|
| 336 |
+
|
| 337 |
|
| 338 |
+
bot_response = response.output[0].content[0].text
|
| 339 |
+
|
| 340 |
|
| 341 |
return jsonify({
|
| 342 |
"success": True,
|