Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ load_dotenv()
|
|
| 14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 15 |
|
| 16 |
|
| 17 |
-
OPENAI_TOKEN = os.getenv("
|
| 18 |
|
| 19 |
# --- Basic Agent Definition ---
|
| 20 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
@@ -26,7 +26,10 @@ class SlpMultiAgent:
|
|
| 26 |
fixed_answer = "This is a default answer."
|
| 27 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 28 |
|
| 29 |
-
#
|
|
|
|
|
|
|
|
|
|
| 30 |
model = OpenAIServerModel(
|
| 31 |
model_id="gpt-3.5-turbo",
|
| 32 |
temperature=0.0,
|
|
@@ -57,7 +60,7 @@ class SlpMultiAgent:
|
|
| 57 |
max_steps=15,
|
| 58 |
final_answer_checks=[check_reasoning]
|
| 59 |
)
|
| 60 |
-
manager_agent.run("""
|
| 61 |
You are a question answering agent. That specializes in complex questions that require multiple steps to answer.
|
| 62 |
Take a few steps and think about the question before answering.
|
| 63 |
You can use the tools available to you, but you should not use them unless necessary.
|
|
@@ -69,7 +72,7 @@ class SlpMultiAgent:
|
|
| 69 |
|
| 70 |
Never try to process strings using code: when you have a string to read, just print it and you'll see it.
|
| 71 |
|
| 72 |
-
Here is the question: {
|
| 73 |
Thoughts: [your reasoning about how to solve the problem]
|
| 74 |
Code:
|
| 75 |
```py
|
|
|
|
| 14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 15 |
|
| 16 |
|
| 17 |
+
OPENAI_TOKEN = os.getenv("OPENAI_API_KEY")
|
| 18 |
|
| 19 |
# --- Basic Agent Definition ---
|
| 20 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
|
| 26 |
fixed_answer = "This is a default answer."
|
| 27 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 28 |
|
| 29 |
+
# Truncate question to avoid exceeding model context length
|
| 30 |
+
MAX_QUESTION_LENGTH = 1000
|
| 31 |
+
short_question = question[:MAX_QUESTION_LENGTH]
|
| 32 |
+
|
| 33 |
model = OpenAIServerModel(
|
| 34 |
model_id="gpt-3.5-turbo",
|
| 35 |
temperature=0.0,
|
|
|
|
| 60 |
max_steps=15,
|
| 61 |
final_answer_checks=[check_reasoning]
|
| 62 |
)
|
| 63 |
+
manager_agent.run(f"""
|
| 64 |
You are a question answering agent. That specializes in complex questions that require multiple steps to answer.
|
| 65 |
Take a few steps and think about the question before answering.
|
| 66 |
You can use the tools available to you, but you should not use them unless necessary.
|
|
|
|
| 72 |
|
| 73 |
Never try to process strings using code: when you have a string to read, just print it and you'll see it.
|
| 74 |
|
| 75 |
+
Here is the question: {short_question}
|
| 76 |
Thoughts: [your reasoning about how to solve the problem]
|
| 77 |
Code:
|
| 78 |
```py
|