ka1kuk commited on
Commit
b216cb2
·
verified ·
1 Parent(s): 06bbd1d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +19 -5
main.py CHANGED
@@ -1,8 +1,8 @@
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
  {
@@ -13,7 +13,7 @@ model = model.bind(
13
  "properties": {
14
  "location": {
15
  "type": "string",
16
- "description": "The city and state, " "e.g. San Francisco, CA",
17
  },
18
  "unit": {
19
  "type": "string",
@@ -27,5 +27,19 @@ model = model.bind(
27
  function_call={"name": "get_current_weather"},
28
  )
29
 
30
- user_input = st.text_input("Enter your question:")
31
- model.invoke(user_input)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  from langchain_experimental.llms.ollama_functions import OllamaFunctions
3
 
4
+ # Initialize the Ollama model
5
  model = OllamaFunctions(model="gemma:7b")
 
6
  model = model.bind(
7
  functions=[
8
  {
 
13
  "properties": {
14
  "location": {
15
  "type": "string",
16
+ "description": "The city and state, e.g., San Francisco, CA",
17
  },
18
  "unit": {
19
  "type": "string",
 
27
  function_call={"name": "get_current_weather"},
28
  )
29
 
30
+ # Function to be called by the Gradio interface
31
+ def get_weather(user_input):
32
+ result = model.invoke(user_input)
33
+ return result
34
+
35
+ # Create the Gradio interface
36
+ iface = gr.Interface(
37
+ fn=get_weather,
38
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter Location and Unit (e.g., 'San Francisco, CA', 'celsius')"),
39
+ outputs="text",
40
+ title="Weather Information",
41
+ description="Enter a location to get the current weather."
42
+ )
43
+
44
+ # Launch the application
45
+ iface.launch()