Spaces:
Runtime error
Runtime error
| from langchain_community.llms import OpenAI | |
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| import streamlit as st | |
| def get_answers(questions,model): | |
| answer_prompt = (f"I want you to become a teacher answer this specific Question: {questions}. You should gave me a straightforward and consise explanation and answer to each one of them") | |
| llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"]) | |
| answers = llm.invoke(answer_prompt) | |
| answers = answers.content | |
| # return questions.content | |
| return(answers) | |
| def GetLLMResponse(selected_topic_level, selected_topic,num_quizzes, model): | |
| question_prompt = (f'You are an AI interview assistant that helps generate customized interview questions for various technical and non-technical roles. Your task is to create a set of interview questions based on the {selected_topic_level} and topic : {selected_topic}. Generate only {num_quizzes} questions ') | |
| if model == "Open AI": | |
| llm = OpenAI(temperature=0.8, openai_api_key=st.secrets["OPENAI_API_KEY"]) | |
| questions = llm(question_prompt) | |
| elif model == "Gemini": | |
| llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"]) | |
| questions = llm.invoke(question_prompt) | |
| questions = questions.content | |
| # return questions.content | |
| answers = get_answers(questions,model) | |
| return(questions,answers) | |