Commit
·
f1879ec
1
Parent(s):
58cfdf8
fix
Browse files- core_agent.py +1 -0
- local_test.py +9 -6
core_agent.py
CHANGED
@@ -221,6 +221,7 @@ class GAIAAgent:
|
|
221 |
print(f"Using Hugging Face token: {api_key[:5]}...")
|
222 |
|
223 |
self.model = HfApiModel(
|
|
|
224 |
model_id=model_id or "meta-llama/Llama-3-70B-Instruct",
|
225 |
token=api_key,
|
226 |
temperature=temperature
|
|
|
221 |
print(f"Using Hugging Face token: {api_key[:5]}...")
|
222 |
|
223 |
self.model = HfApiModel(
|
224 |
+
# Important to request access to the model
|
225 |
model_id=model_id or "meta-llama/Llama-3-70B-Instruct",
|
226 |
token=api_key,
|
227 |
temperature=temperature
|
local_test.py
CHANGED
@@ -89,7 +89,7 @@ def initialize_agent():
|
|
89 |
print("Initializing GAIAAgent with API keys...")
|
90 |
|
91 |
# Try X.AI first (xAI) with the correct API endpoint
|
92 |
-
if os.getenv("XAI_API_KEY"):
|
93 |
print("Using X.AI API key")
|
94 |
try:
|
95 |
agent = GAIAAgent(
|
@@ -100,7 +100,6 @@ def initialize_agent():
|
|
100 |
temperature=0.2,
|
101 |
executor_type="local",
|
102 |
verbose=True,
|
103 |
-
system_prompt_suffix=additional_system_prompt # Add our hints
|
104 |
)
|
105 |
print("Using OpenAIServerModel with X.AI API")
|
106 |
return agent
|
@@ -109,7 +108,7 @@ def initialize_agent():
|
|
109 |
traceback.print_exc()
|
110 |
|
111 |
# Then try OpenAI
|
112 |
-
if os.getenv("OPENAI_API_KEY"):
|
113 |
print("Using OpenAI API key")
|
114 |
try:
|
115 |
model_id = os.getenv("AGENT_MODEL_ID", "gpt-4o")
|
@@ -128,11 +127,14 @@ def initialize_agent():
|
|
128 |
traceback.print_exc()
|
129 |
|
130 |
# Last resort, try Hugging Face
|
131 |
-
if os.getenv("HUGGINGFACEHUB_API_TOKEN"):
|
132 |
print("Using Hugging Face API token")
|
133 |
try:
|
134 |
-
#
|
135 |
-
model_id = "tiiuae/falcon-7b-instruct"
|
|
|
|
|
|
|
136 |
agent = GAIAAgent(
|
137 |
model_type="HfApiModel",
|
138 |
model_id=model_id,
|
@@ -234,6 +236,7 @@ if __name__ == "__main__":
|
|
234 |
|
235 |
# Print environment information
|
236 |
print("\nEnvironment information:")
|
|
|
237 |
print(f"XAI_API_KEY set: {'Yes' if os.getenv('XAI_API_KEY') else 'No'}")
|
238 |
print(f"OPENAI_API_KEY set: {'Yes' if os.getenv('OPENAI_API_KEY') else 'No'}")
|
239 |
print(f"HUGGINGFACEHUB_API_TOKEN set: {'Yes' if os.getenv('HUGGINGFACEHUB_API_TOKEN') else 'No'}")
|
|
|
89 |
print("Initializing GAIAAgent with API keys...")
|
90 |
|
91 |
# Try X.AI first (xAI) with the correct API endpoint
|
92 |
+
if os.getenv("XAI_API_KEY") and os.getenv("API_TO_USE") == "xai":
|
93 |
print("Using X.AI API key")
|
94 |
try:
|
95 |
agent = GAIAAgent(
|
|
|
100 |
temperature=0.2,
|
101 |
executor_type="local",
|
102 |
verbose=True,
|
|
|
103 |
)
|
104 |
print("Using OpenAIServerModel with X.AI API")
|
105 |
return agent
|
|
|
108 |
traceback.print_exc()
|
109 |
|
110 |
# Then try OpenAI
|
111 |
+
if os.getenv("OPENAI_API_KEY") and os.getenv("API_TO_USE") == "openai":
|
112 |
print("Using OpenAI API key")
|
113 |
try:
|
114 |
model_id = os.getenv("AGENT_MODEL_ID", "gpt-4o")
|
|
|
127 |
traceback.print_exc()
|
128 |
|
129 |
# Last resort, try Hugging Face
|
130 |
+
if os.getenv("HUGGINGFACEHUB_API_TOKEN") and os.getenv("API_TO_USE") == "huggingface":
|
131 |
print("Using Hugging Face API token")
|
132 |
try:
|
133 |
+
# model_id = "tiiuae/Falcon3-7B-Base"
|
134 |
+
# model_id = "tiiuae/falcon-7b-instruct"
|
135 |
+
# IMPORTANT: Falcon models are not working for me.
|
136 |
+
model_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
137 |
+
|
138 |
agent = GAIAAgent(
|
139 |
model_type="HfApiModel",
|
140 |
model_id=model_id,
|
|
|
236 |
|
237 |
# Print environment information
|
238 |
print("\nEnvironment information:")
|
239 |
+
print(f"API_TO_USE: {os.getenv('API_TO_USE', 'huggingface')} (default: huggingface)")
|
240 |
print(f"XAI_API_KEY set: {'Yes' if os.getenv('XAI_API_KEY') else 'No'}")
|
241 |
print(f"OPENAI_API_KEY set: {'Yes' if os.getenv('OPENAI_API_KEY') else 'No'}")
|
242 |
print(f"HUGGINGFACEHUB_API_TOKEN set: {'Yes' if os.getenv('HUGGINGFACEHUB_API_TOKEN') else 'No'}")
|