File size: 1,358 Bytes
af56ee5
 
5875333
 
 
 
af56ee5
 
be577bd
d90ab14
af56ee5
 
 
 
 
 
 
 
 
 
 
 
 
cf96b71
af56ee5
 
 
 
 
 
 
cf96b71
 
af56ee5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
import openai
import sys
import os

os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")

def generate_text(prompt):
    # Add custom text to the prompt 
    input_text = prompt + "You are an expert with  many years experience in the insurance loss adjusting business. Can you give your expert opinion on the question or statement made at the start of this prompt. Answer it in terms of the laws regulations and terms of the insurance industry. Make it accurate, but written in a simple and clear style. Please provide references or insurance law precedents where possible."    # 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="What do you wish to know about insurance")
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="AI Adjuster",
    description="AI tool to help you understand and answer any insurance related queries."
)
gradio_app.launch()