Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +42 -0
- embedchain.json +3 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from embedchain import Pipeline as App
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
os.environ["GOOGLE_API_KEY"] = "AIzaSyBbruzn10nez-0a-_60TA9R9h6qumLD1Es"
|
| 6 |
+
|
| 7 |
+
app = App.from_config(config={
|
| 8 |
+
"llm": {
|
| 9 |
+
"provider": "google",
|
| 10 |
+
"config": {
|
| 11 |
+
"model": "gemini-pro",
|
| 12 |
+
"temperature": 0.5,
|
| 13 |
+
"max_tokens": 1000,
|
| 14 |
+
"top_p": 1,
|
| 15 |
+
"stream": False,
|
| 16 |
+
},
|
| 17 |
+
},
|
| 18 |
+
"embedder": {
|
| 19 |
+
"provider": "google",
|
| 20 |
+
"config": {
|
| 21 |
+
"model": "models/embedding-001",
|
| 22 |
+
},
|
| 23 |
+
},
|
| 24 |
+
"chunker": {
|
| 25 |
+
"chunk_size": 2000,
|
| 26 |
+
"chunk_overlap": 0,
|
| 27 |
+
"length_function": "len",
|
| 28 |
+
},
|
| 29 |
+
})
|
| 30 |
+
|
| 31 |
+
app.add('http://www.droit-afrique.com/uploads/Gabon-Code-2019-penal.pdf', data_type='pdf_file')
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def query(message, history):
|
| 37 |
+
return app.chat(message)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
demo = gr.ChatInterface(query)
|
| 41 |
+
|
| 42 |
+
demo.launch()
|
embedchain.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"provider": "gradio.app"
|
| 3 |
+
}
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.11.0
|
| 2 |
+
embedchain
|