Update main.py
Browse files
main.py
CHANGED
@@ -1,44 +1,18 @@
|
|
1 |
-
import
|
2 |
-
from langchain_experimental.llms.ollama_functions import OllamaFunctions
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
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 |
-
def
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
inputs=[gr.Textbox(label="Location (e.g., 'San Francisco, CA')"), gr.Radio(choices=["celsius", "fahrenheit"], label="Unit")],
|
38 |
-
outputs=gr.Text(label="Weather Information"),
|
39 |
-
title="Weather Information",
|
40 |
-
description="Enter a location and select the unit to get the current weather.",
|
41 |
-
allow_flagging="never"
|
42 |
-
)
|
43 |
-
|
44 |
-
iface.launch()
|
|
|
1 |
+
import subprocess
|
|
|
2 |
|
3 |
+
def run_command(command):
|
4 |
+
try:
|
5 |
+
result = subprocess.run(command, shell=True, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
6 |
+
print(f"Success: {result.stdout}")
|
7 |
+
except subprocess.CalledProcessError as e:
|
8 |
+
print(f"Error: {e.stderr}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
def main(model):
|
11 |
+
# Install script
|
12 |
+
run_command("curl -fsSL https://ollama.com/install.sh | sh")
|
13 |
+
|
14 |
+
# Start Ollama server
|
15 |
+
run_command("ollama serve")
|
16 |
|
17 |
+
if __name__ == "__main__":
|
18 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|