saikanov commited on
Commit
d36cfea
·
verified ·
1 Parent(s): 78ec097

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -8,13 +8,14 @@ from langchain_core.prompts import PromptTemplate
8
  import chromadb
9
  import os
10
  from uuid import uuid4
 
11
 
12
  # Initialize persistent client
13
  CHROMA_PATH = "./vectordb-chroma/gformdb"
14
  os.makedirs(CHROMA_PATH, exist_ok=True)
15
  default_user_aspek = "Jika Jawaban salah berikan nilai 0, jika jawaban benar namun tidak tepat berikan nilai 50, jika jawaban benar dan lengkap serta penjelasan baik, beri nilai 100"
16
 
17
- def process_files(csv_file, openai_key, user_aspek=default_user_aspek, pdf_file=False, model_name="gpt-4o-mini"):
18
  try:
19
  context = ""
20
 
@@ -57,10 +58,9 @@ def process_files(csv_file, openai_key, user_aspek=default_user_aspek, pdf_file=
57
  return qa_efficient, Question
58
 
59
  # Set OpenAI API
60
- if openai_key == "":
61
- openai_key = os.getenv('OPENAI_API_KEY')
62
 
63
- os.environ["OPENAI_API_KEY"] = openai_key
64
 
65
  # Process CSV (Gradio provides the file path directly)
66
 
@@ -129,7 +129,7 @@ def process_files(csv_file, openai_key, user_aspek=default_user_aspek, pdf_file=
129
  )
130
 
131
  # Initialize ChatGPT
132
- chat = ChatOpenAI(model=model_name)
133
  chain = PROMPT | chat
134
 
135
  # Generate evaluation
@@ -195,13 +195,13 @@ def create_interface():
195
 
196
  model_name = gr.Textbox(
197
  label="openAI model",
198
- placeholder="input your openAI model",
199
- value="gpt-4o-mini"
200
  )
201
 
202
  api_key = gr.Textbox(
203
  label="OpenAI API Key",
204
- placeholder="Enter your OpenAI API key, default is my API key, use it wisely XD",
205
  type="password"
206
  )
207
 
 
8
  import chromadb
9
  import os
10
  from uuid import uuid4
11
+ from langchain_google_genai import ChatGoogleGenerativeAI
12
 
13
  # Initialize persistent client
14
  CHROMA_PATH = "./vectordb-chroma/gformdb"
15
  os.makedirs(CHROMA_PATH, exist_ok=True)
16
  default_user_aspek = "Jika Jawaban salah berikan nilai 0, jika jawaban benar namun tidak tepat berikan nilai 50, jika jawaban benar dan lengkap serta penjelasan baik, beri nilai 100"
17
 
18
+ def process_files(csv_file, gemini_key, user_aspek=default_user_aspek, pdf_file=False, model):
19
  try:
20
  context = ""
21
 
 
58
  return qa_efficient, Question
59
 
60
  # Set OpenAI API
61
+ if gemini_key == "":
62
+ gemini_key = os.getenv('GEMINI_API_KEY')
63
 
 
64
 
65
  # Process CSV (Gradio provides the file path directly)
66
 
 
129
  )
130
 
131
  # Initialize ChatGPT
132
+ chat = ChatGoogleGenerativeAI(model=model, api_key=gemini_key)
133
  chain = PROMPT | chat
134
 
135
  # Generate evaluation
 
195
 
196
  model_name = gr.Textbox(
197
  label="openAI model",
198
+ placeholder="input your Gemini model",
199
+ value="gemini-1.5-pro"
200
  )
201
 
202
  api_key = gr.Textbox(
203
  label="OpenAI API Key",
204
+ placeholder="Enter your Gemini API key, default is my API key, use it wisely XD",
205
  type="password"
206
  )
207