import gradio as gr import openai openai.api_key = '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' def generate_text(prompt): # Add custom text to the prompt input_text = "using only information in the book property insurance claims - law and practice please answer the following query" + prompt # Generate text using OpenAI API response = openai.Completion.create( engine="text-davinci-002", prompt=input_text, max_tokens=1024, n=1, stop=None, temperature=0.7 ) # Return the generated text return response.choices[0].text.strip() # Define the input and output interfaces using Gradio input_text = gr.inputs.Textbox(label="Please enter your date of Birth and where you were born") output_text = gr.outputs.Textbox(label="Generated text:") # Create the Gradio app and run it gradio_app = gr.Interface( fn=generate_text, inputs=input_text, outputs=output_text, title="InternetAdjsuterBot", description="An AI Bot that answers queries based on the loss adjsuter bible" ) gradio_app.launch()