File size: 1,380 Bytes
a28f976
 
 
 
 
cc8f417
a28f976
 
cc8f417
a28f976
 
 
 
 
cc8f417
 
 
a28f976
 
 
 
 
 
 
 
f10904c
a28f976
 
cc8f417
a28f976
 
 
 
cc8f417
1c19215
 
cc8f417
 
 
 
a28f976
 
 
 
 
cc8f417
a28f976
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
37
38
39
40
41
42
43
44
45
46
47
48
import gradio as gr
import os
import openai
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Azure OpenAI Configuration
openai.api_type = "azure"
openai.api_base = os.getenv("AZURE_API_ENDPOINT")
openai.api_key = os.getenv("AZURE_API_KEY")

def compare_claims(claim1, claim2):
    """
    Function to compare two claims using Azure OpenAI's GPT model.
    """
    response = openai.ChatCompletion.create(
        engine="gpt-4",
        messages=[
            {"role": "system", "content": "You are an AI specialized in claim comparison."},
            {"role": "user", "content": f"Compare these two claims:\nClaim 1: {claim1}\nClaim 2: {claim2}\nWhat are the differences?"}
        ]
    )
    return response["choices"][0]["message"]["content"]

def main():
    """
    Launch the Gradio interface for claim comparison.
    """
    # Define the Gradio interface
    interface = gr.Interface(
        fn=compare_claims,
        inputs=[
            gr.Textbox(label="claim1", placeholder="Enter first claim description..."),
            gr.Textbox(label="claim2", placeholder="Enter second claim description...")
        ],
        outputs="text",
        title="Claims Comparison",
        description="Enter two claims to compare their differences."
    )

    # Launch the Gradio app
    interface.launch()

if __name__ == "__main__":
    main()