Upload 3 files
Browse files- skills/serch.py +8 -0
- skills/vision.py +38 -0
- skills/wiki.py +9 -0
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/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)
|