import gradio as gr import openai import os # Load your OpenAI API key from the environment variable openai.api_key = os.getenv("OPENAI_API_KEY") # Read the static CV file def load_cv(): with open("templated_CV.txt", 'r') as file: return file.read() # Extract information from the CV cv_text = load_cv() def chat_with_ai(user_input): prompt = f"{cv_text}\n\nUser: {user_input}\nAI:" response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "user", "content": prompt} ] ) return response.choices[0].message['content'] def main(user_input): response = chat_with_ai(user_input) return response iface = gr.Interface( fn=main, inputs=gr.Textbox(label="Ask a question, that you would like to ask Karthik"), outputs="text", title="AI Clone", description="Interact with an AI clone for recruiting or for fun :) " ) iface.launch()