Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,31 @@ import numpy as np
|
|
3 |
import gradio as gr
|
4 |
import chromadb
|
5 |
|
6 |
-
from transformers import AutoModel, AutoTokenizer,
|
7 |
import torch
|
8 |
import chromadb
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
# Initialize ChromaDB client
|
11 |
chroma_client = chromadb.PersistentClient(path="./chroma_db") # Stores data persistently
|
12 |
collection = chroma_client.get_or_create_collection(name="wikipedia_docs")
|
@@ -85,4 +106,5 @@ iface = gr.Interface(
|
|
85 |
description="Enter a query and retrieve relevant Wikipedia passages."
|
86 |
)
|
87 |
|
88 |
-
iface.launch()
|
|
|
|
3 |
import gradio as gr
|
4 |
import chromadb
|
5 |
|
6 |
+
from transformers import AutoModel, AutoTokenizer, pipeline
|
7 |
import torch
|
8 |
import chromadb
|
9 |
|
10 |
+
import os
|
11 |
+
|
12 |
+
# Ensure the token is set
|
13 |
+
hf_token = os.getenv("HF_Token")
|
14 |
+
|
15 |
+
if not hf_token:
|
16 |
+
raise ValueError("HF_Token is not set. Please check your Hugging Face Secrets.")
|
17 |
+
|
18 |
+
# Load LLaMA-2 model with authentication
|
19 |
+
llama_pipe = pipeline(
|
20 |
+
"text-generation",
|
21 |
+
model="meta-llama/Llama-2-7b-chat-hf",
|
22 |
+
token=hf_token # Pass the token explicitly
|
23 |
+
)
|
24 |
+
|
25 |
+
# Test LLaMA-2 inference
|
26 |
+
output = llama_pipe("What is machine learning?", max_length=100)
|
27 |
+
print(output)
|
28 |
+
|
29 |
+
|
30 |
+
'''
|
31 |
# Initialize ChromaDB client
|
32 |
chroma_client = chromadb.PersistentClient(path="./chroma_db") # Stores data persistently
|
33 |
collection = chroma_client.get_or_create_collection(name="wikipedia_docs")
|
|
|
106 |
description="Enter a query and retrieve relevant Wikipedia passages."
|
107 |
)
|
108 |
|
109 |
+
iface.launch()
|
110 |
+
'''
|