Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain_experimental.llms.ollama_functions import OllamaFunctions
|
| 3 |
+
|
| 4 |
+
model = OllamaFunctions(model="gemma:7b")
|
| 5 |
+
|
| 6 |
+
model = model.bind(
|
| 7 |
+
functions=[
|
| 8 |
+
{
|
| 9 |
+
"name": "get_current_weather",
|
| 10 |
+
"description": "Get the current weather in a given location",
|
| 11 |
+
"parameters": {
|
| 12 |
+
"type": "object",
|
| 13 |
+
"properties": {
|
| 14 |
+
"location": {
|
| 15 |
+
"type": "string",
|
| 16 |
+
"description": "The city and state, " "e.g. San Francisco, CA",
|
| 17 |
+
},
|
| 18 |
+
"unit": {
|
| 19 |
+
"type": "string",
|
| 20 |
+
"enum": ["celsius", "fahrenheit"],
|
| 21 |
+
},
|
| 22 |
+
},
|
| 23 |
+
"required": ["location"],
|
| 24 |
+
},
|
| 25 |
+
}
|
| 26 |
+
],
|
| 27 |
+
function_call={"name": "get_current_weather"},
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
user_input = st.text_input("Enter your question:")
|
| 31 |
+
model.invoke(user_input)
|