AI-Clone / app.py
Karthik Raja
Update app.py
f8d30bb verified
raw
history blame
1.06 kB
import gradio as gr
import openai
import os
from openai import OpenAI
client = OpenAI()
# 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):
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "You are a helpful assistant that can only answer questions about Karthik Raja"},
{"role": "user", "{cv_text}\n\nUser: {user_input}"}
]
)
return completion.choices[0].message
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()