Spaces:
Sleeping
Sleeping
Alexandre Gazola
commited on
Commit
·
a419591
1
Parent(s):
98e197a
test
Browse files- app.py +7 -1
- constants.py +1 -1
- image_to_text_tool.py +3 -0
- langchain_agent.py +2 -1
app.py
CHANGED
@@ -6,7 +6,7 @@ import inspect
|
|
6 |
import pandas as pd
|
7 |
import time
|
8 |
from langchain_agent import LangChainAgent
|
9 |
-
|
10 |
from utils import get_bytes, get_text_file_contents, get_base64
|
11 |
|
12 |
# (Keep Constants as is) ok!!!
|
@@ -42,6 +42,12 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
42 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
43 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
44 |
print(agent_code)
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
# 2. Fetch Questions
|
47 |
print(f"Fetching questions from: {questions_url}")
|
|
|
6 |
import pandas as pd
|
7 |
import time
|
8 |
from langchain_agent import LangChainAgent
|
9 |
+
from analyse_chess_position_tool import get_best_move
|
10 |
from utils import get_bytes, get_text_file_contents, get_base64
|
11 |
|
12 |
# (Keep Constants as is) ok!!!
|
|
|
42 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
43 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
44 |
print(agent_code)
|
45 |
+
|
46 |
+
print('testing chess best move for FEN 3r2k1/pp3pp1/4b2p/7Q/3n4/PqBBR2P/5PP1/6K1 b - - 0 1...')
|
47 |
+
move = get_best_move('3r2k1/pp3pp1/4b2p/7Q/3n4/PqBBR2P/5PP1/6K1 b - - 0 1')
|
48 |
+
print(move)
|
49 |
+
|
50 |
+
return "Fetched questions list is empty or invalid format.", None
|
51 |
|
52 |
# 2. Fetch Questions
|
53 |
print(f"Fetching questions from: {questions_url}")
|
constants.py
CHANGED
@@ -21,7 +21,7 @@ PROMPT_LIMITADOR_LLM = """
|
|
21 |
Do not attempt to:
|
22 |
- Access external websites or databases without the tools that I provide.
|
23 |
- Use any internal knowledge base beyond what I provide.
|
24 |
-
-
|
25 |
- Categorize food items based on your own knowledge. Use the provided tools. Run the provided tools on every item of the grocery list!
|
26 |
- Make assumptions or inferences based on information not explicitly given.
|
27 |
- Utilize any built-in tools or functions that I have not specifically presented.
|
|
|
21 |
Do not attempt to:
|
22 |
- Access external websites or databases without the tools that I provide.
|
23 |
- Use any internal knowledge base beyond what I provide.
|
24 |
+
- Interpret images on your own. If you need to interpret or analyse an image, use the tool that converts the image into text.
|
25 |
- Categorize food items based on your own knowledge. Use the provided tools. Run the provided tools on every item of the grocery list!
|
26 |
- Make assumptions or inferences based on information not explicitly given.
|
27 |
- Utilize any built-in tools or functions that I have not specifically presented.
|
image_to_text_tool.py
CHANGED
@@ -32,6 +32,9 @@ def image_to_text(image_base64_str, instructions):
|
|
32 |
instructions
|
33 |
]
|
34 |
)
|
|
|
|
|
|
|
35 |
return response.text
|
36 |
|
37 |
if __name__ == '__main__':
|
|
|
32 |
instructions
|
33 |
]
|
34 |
)
|
35 |
+
|
36 |
+
print('generated text from image: ' + response.text)
|
37 |
+
|
38 |
return response.text
|
39 |
|
40 |
if __name__ == '__main__':
|
langchain_agent.py
CHANGED
@@ -20,7 +20,8 @@ class LangChainAgent:
|
|
20 |
llm = ChatGoogleGenerativeAI(
|
21 |
model=constants.MODEL,
|
22 |
api_key=constants.API_KEY,
|
23 |
-
temperature=0.7
|
|
|
24 |
|
25 |
tools = [
|
26 |
wikipedia_revision_by_year_keyword,
|
|
|
20 |
llm = ChatGoogleGenerativeAI(
|
21 |
model=constants.MODEL,
|
22 |
api_key=constants.API_KEY,
|
23 |
+
temperature=0.7,
|
24 |
+
timeout=20)
|
25 |
|
26 |
tools = [
|
27 |
wikipedia_revision_by_year_keyword,
|