Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,15 +1,29 @@
|
|
1 |
import requests
|
2 |
import os
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/all-MiniLM-L6-v2"
|
5 |
bearer = "Bearer " + os.getenv('TOKEN')
|
6 |
headers = {"Authorization": bearer }
|
7 |
|
8 |
-
from flask import Flask
|
9 |
app = Flask(__name__)
|
10 |
|
11 |
@app.route('/app')
|
12 |
def command_app():
|
|
|
|
|
13 |
payload ={
|
14 |
"inputs": {
|
15 |
"source_sentence": "That is a happy person",
|
@@ -20,8 +34,9 @@ def command_app():
|
|
20 |
]
|
21 |
},
|
22 |
}
|
|
|
23 |
response = requests.post(API_URL, headers=headers, json=payload)
|
24 |
-
return response.json()
|
25 |
|
26 |
@app.route('/')
|
27 |
def command_server():
|
|
|
1 |
import requests
|
2 |
import os
|
3 |
|
4 |
+
from langchain_core.tools import Tool
|
5 |
+
from langchain_google_community import GoogleSearchAPIWrapper
|
6 |
+
|
7 |
+
from flask import Flask
|
8 |
+
|
9 |
+
search = GoogleSearchAPIWrapper()
|
10 |
+
|
11 |
+
tool = Tool(
|
12 |
+
name="google_search",
|
13 |
+
description="Search Google for recent results.",
|
14 |
+
func=search.run,
|
15 |
+
)
|
16 |
+
|
17 |
API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/all-MiniLM-L6-v2"
|
18 |
bearer = "Bearer " + os.getenv('TOKEN')
|
19 |
headers = {"Authorization": bearer }
|
20 |
|
|
|
21 |
app = Flask(__name__)
|
22 |
|
23 |
@app.route('/app')
|
24 |
def command_app():
|
25 |
+
res = tool.run("Obama's first name?")
|
26 |
+
|
27 |
payload ={
|
28 |
"inputs": {
|
29 |
"source_sentence": "That is a happy person",
|
|
|
34 |
]
|
35 |
},
|
36 |
}
|
37 |
+
|
38 |
response = requests.post(API_URL, headers=headers, json=payload)
|
39 |
+
return response.json() + "-" + res
|
40 |
|
41 |
@app.route('/')
|
42 |
def command_server():
|