Upload 5 files
Browse files- skills/control_mode.py +22 -0
- skills/serch.py +8 -0
- skills/utils.py +5 -0
- skills/vision.py +38 -0
- skills/wiki.py +9 -0
skills/control_mode.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
def manual_control_mode(command):
|
6 |
+
url = "https://srivatsavdamaraju-central-robot-server.hf.space/activate_manual_mode"
|
7 |
+
payload = {}
|
8 |
+
headers = {}
|
9 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
10 |
+
print(response.text)
|
11 |
+
return "this is manual control mode"
|
12 |
+
|
13 |
+
|
14 |
+
def deactivate_manual_control_mode(command):
|
15 |
+
url = (
|
16 |
+
"https://srivatsavdamaraju-central-robot-server.hf.space/deactivate_manual_mode"
|
17 |
+
)
|
18 |
+
payload = {}
|
19 |
+
headers = {}
|
20 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
21 |
+
print(response.text)
|
22 |
+
return "this is deActivate manual control mode"
|
skills/serch.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /skills/search_tool.py
|
2 |
+
|
3 |
+
from langchain.tools import DuckDuckGoSearchRun
|
4 |
+
|
5 |
+
search = DuckDuckGoSearchRun()
|
6 |
+
|
7 |
+
def search_tool(query):
|
8 |
+
return search.run(query)
|
skills/utils.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def fix_base64_padding(base64_string: str) -> str:
|
2 |
+
padding_needed = len(base64_string) % 4
|
3 |
+
if padding_needed:
|
4 |
+
base64_string += '=' * (4 - padding_needed)
|
5 |
+
return base64_string
|
skills/vision.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /skills/image_analysis.py
|
2 |
+
|
3 |
+
import base64
|
4 |
+
from groq import Groq
|
5 |
+
|
6 |
+
# Function to encode the image
|
7 |
+
def encode_image(image_file):
|
8 |
+
return base64.b64encode(image_file.read()).decode('utf-8')
|
9 |
+
|
10 |
+
def get_chat_completion(query, image_file=None):
|
11 |
+
client = Groq()
|
12 |
+
|
13 |
+
messages = [
|
14 |
+
{
|
15 |
+
"role": "user",
|
16 |
+
"content": [
|
17 |
+
{"type": "text", "text": query},
|
18 |
+
],
|
19 |
+
}
|
20 |
+
]
|
21 |
+
|
22 |
+
if image_file:
|
23 |
+
base64_image = encode_image(image_file)
|
24 |
+
messages[0]["content"].append(
|
25 |
+
{
|
26 |
+
"type": "image_url",
|
27 |
+
"image_url": {
|
28 |
+
"url": f"data:image/jpeg;base64,{base64_image}",
|
29 |
+
},
|
30 |
+
}
|
31 |
+
)
|
32 |
+
|
33 |
+
chat_completion = client.chat.completions.create(
|
34 |
+
messages=messages,
|
35 |
+
model="llama-3.2-11b-vision-preview",
|
36 |
+
)
|
37 |
+
|
38 |
+
return chat_completion.choices[0].message.content
|
skills/wiki.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /skills/wikipedia_tool.py
|
2 |
+
|
3 |
+
from langchain.tools import WikipediaQueryRun
|
4 |
+
from langchain_community.utilities import WikipediaAPIWrapper
|
5 |
+
|
6 |
+
wikipedia = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper())
|
7 |
+
|
8 |
+
def wikipedia_tool(query):
|
9 |
+
return wikipedia.run(query)
|