Spaces:
Sleeping
Sleeping
Update llm_node.py
Browse files- llm_node.py +27 -10
llm_node.py
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def llm_node(question, search_result):
|
| 2 |
-
#
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
)
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from langchain_community.chat_models import ChatOpenAI
|
| 3 |
+
|
| 4 |
def llm_node(question, search_result):
|
| 5 |
+
# Initialize GPT-4
|
| 6 |
+
llm = ChatOpenAI(
|
| 7 |
+
model="gpt-4",
|
| 8 |
+
temperature=0,
|
| 9 |
+
openai_api_key=os.getenv("OPENAI_API_KEY")
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
prompt = f"""You are solving a GAIA benchmark evaluation question.
|
| 13 |
+
|
| 14 |
+
Here’s the question:
|
| 15 |
+
{question}
|
| 16 |
+
|
| 17 |
+
Here’s retrieved information:
|
| 18 |
+
{search_result}
|
| 19 |
+
|
| 20 |
+
⚠️ VERY IMPORTANT:
|
| 21 |
+
- ONLY return the final answer, exactly as required.
|
| 22 |
+
- Do NOT include explanations, prefixes, or notes.
|
| 23 |
+
- If the question asks for a list, give only the list, in the requested format.
|
| 24 |
+
|
| 25 |
+
Your answer:"""
|
| 26 |
+
|
| 27 |
+
response = llm.invoke(prompt)
|
| 28 |
+
return response.content.strip()
|