Spaces:
Runtime error
Runtime error
rajsinghparihar commited on
Commit ·
28f535f
1
Parent(s): b576c56
default groq api key set in repo secrets
Browse files
app.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from rag import RAG, ServiceContextModule
|
| 3 |
from llama_index.core import set_global_service_context
|
| 4 |
-
from dotenv import load_dotenv
|
| 5 |
import json
|
| 6 |
from prompts import general_prompt
|
| 7 |
from gradio_pdf import PDF
|
| 8 |
import requests
|
|
|
|
| 9 |
|
| 10 |
service_context_module = None
|
| 11 |
current_model = None
|
|
@@ -14,7 +14,6 @@ current_model = None
|
|
| 14 |
def initialize(api_key, model_name):
|
| 15 |
global service_context_module, current_model
|
| 16 |
gr.Info("Initializing app")
|
| 17 |
-
load_dotenv(override=True)
|
| 18 |
url = "https://api.groq.com/openai/v1/models"
|
| 19 |
headers = {
|
| 20 |
"Authorization": f"Bearer {api_key}",
|
|
@@ -85,8 +84,14 @@ Created by [@rajsinghparihar](https://huggingface.co/rajsinghparihar) for extrac
|
|
| 85 |
)
|
| 86 |
with gr.Tab(label="Init Section") as init_tab:
|
| 87 |
with gr.Row():
|
| 88 |
-
api_key = gr.Text(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
available_models = gr.Dropdown(
|
|
|
|
| 90 |
label="Choose your LLM",
|
| 91 |
choices=[
|
| 92 |
"gemma-7b-it",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from rag import RAG, ServiceContextModule
|
| 3 |
from llama_index.core import set_global_service_context
|
|
|
|
| 4 |
import json
|
| 5 |
from prompts import general_prompt
|
| 6 |
from gradio_pdf import PDF
|
| 7 |
import requests
|
| 8 |
+
import os
|
| 9 |
|
| 10 |
service_context_module = None
|
| 11 |
current_model = None
|
|
|
|
| 14 |
def initialize(api_key, model_name):
|
| 15 |
global service_context_module, current_model
|
| 16 |
gr.Info("Initializing app")
|
|
|
|
| 17 |
url = "https://api.groq.com/openai/v1/models"
|
| 18 |
headers = {
|
| 19 |
"Authorization": f"Bearer {api_key}",
|
|
|
|
| 84 |
)
|
| 85 |
with gr.Tab(label="Init Section") as init_tab:
|
| 86 |
with gr.Row():
|
| 87 |
+
api_key = gr.Text(
|
| 88 |
+
label="Enter your Groq API KEY",
|
| 89 |
+
type="password",
|
| 90 |
+
)
|
| 91 |
+
if api_key == "" or not api_key:
|
| 92 |
+
api_key = os.getenv("GROQ_API_KEY")
|
| 93 |
available_models = gr.Dropdown(
|
| 94 |
+
value="llama3-70b-8192",
|
| 95 |
label="Choose your LLM",
|
| 96 |
choices=[
|
| 97 |
"gemma-7b-it",
|