Spaces:
Runtime error
Runtime error
kendrickfff
commited on
Commit
•
e345a10
1
Parent(s):
13cd9c6
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,17 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
from langchain_google_genai.chat_models import ChatGoogleGenerativeAI
|
4 |
from PIL import Image
|
5 |
import torch
|
6 |
from torchvision import models, transforms
|
7 |
import json
|
8 |
import requests
|
9 |
|
10 |
-
# Load
|
11 |
-
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
# Initialize the chat model with the necessary credentials
|
17 |
-
llm = ChatGoogleGenerativeAI(model='gemini-1.5-pro')
|
18 |
|
19 |
# Load a pre-trained ResNet50 model for image classification
|
20 |
model = models.resnet50(pretrained=True)
|
@@ -38,7 +35,7 @@ chat_history = []
|
|
38 |
def chat_with_gemini(message):
|
39 |
global chat_history
|
40 |
# Get a response from the language model
|
41 |
-
bot_response = llm.predict(message)
|
42 |
chat_history.append((message, bot_response))
|
43 |
return chat_history
|
44 |
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from langchain_google_genai.chat_models import ChatGoogleGenerativeAI # Import for Gemini
|
4 |
from PIL import Image
|
5 |
import torch
|
6 |
from torchvision import models, transforms
|
7 |
import json
|
8 |
import requests
|
9 |
|
10 |
+
# Load credentials from Hugging Face's Secret Manager
|
11 |
+
hf_token = os.environ.get("HF_TOKEN") # Assuming the Hugging Face API token is set in environment
|
12 |
|
13 |
+
# Initialize Gemini model using Hugging Face
|
14 |
+
llm = ChatGoogleGenerativeAI(model='gemini-1.5-pro') # You can change 'gemini-1.5-pro' to the specific model you need
|
|
|
|
|
|
|
15 |
|
16 |
# Load a pre-trained ResNet50 model for image classification
|
17 |
model = models.resnet50(pretrained=True)
|
|
|
35 |
def chat_with_gemini(message):
|
36 |
global chat_history
|
37 |
# Get a response from the language model
|
38 |
+
bot_response = llm.predict(message) # This will interact with the Gemini model
|
39 |
chat_history.append((message, bot_response))
|
40 |
return chat_history
|
41 |
|