Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,21 +3,18 @@ import os
|
|
| 3 |
import openai
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
-
|
| 7 |
-
# Load .env file
|
| 8 |
load_dotenv()
|
| 9 |
|
| 10 |
-
|
| 11 |
openai.api_type = "azure"
|
| 12 |
openai.api_base = os.getenv("AZURE_API_ENDPOINT")
|
| 13 |
openai.api_key = os.getenv("AZURE_API_KEY")
|
| 14 |
|
| 15 |
-
|
| 16 |
-
# Example Claims
|
| 17 |
-
claim_text1 = "Car accident on highway, minor injuries, estimated damage $5000."
|
| 18 |
-
claim_text2 = "Car collision at intersection, severe injuries, estimated damage $15000."
|
| 19 |
-
|
| 20 |
def compare_claims(claim1, claim2):
|
|
|
|
|
|
|
|
|
|
| 21 |
response = openai.ChatCompletion.create(
|
| 22 |
engine="gpt-4",
|
| 23 |
messages=[
|
|
@@ -27,22 +24,24 @@ def compare_claims(claim1, claim2):
|
|
| 27 |
)
|
| 28 |
return response["choices"][0]["message"]["content"]
|
| 29 |
|
| 30 |
-
|
| 31 |
def main():
|
| 32 |
"""
|
| 33 |
-
Launch the Gradio interface for
|
| 34 |
"""
|
| 35 |
# Define the Gradio interface
|
| 36 |
interface = gr.Interface(
|
| 37 |
fn=compare_claims,
|
| 38 |
-
inputs=
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
# Launch the Gradio app
|
| 45 |
interface.launch()
|
| 46 |
|
| 47 |
-
if __name__ == "__main__":
|
| 48 |
main()
|
|
|
|
| 3 |
import openai
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
+
# Load environment variables
|
|
|
|
| 7 |
load_dotenv()
|
| 8 |
|
| 9 |
+
# Azure OpenAI Configuration
|
| 10 |
openai.api_type = "azure"
|
| 11 |
openai.api_base = os.getenv("AZURE_API_ENDPOINT")
|
| 12 |
openai.api_key = os.getenv("AZURE_API_KEY")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def compare_claims(claim1, claim2):
|
| 15 |
+
"""
|
| 16 |
+
Function to compare two claims using Azure OpenAI's GPT model.
|
| 17 |
+
"""
|
| 18 |
response = openai.ChatCompletion.create(
|
| 19 |
engine="gpt-4",
|
| 20 |
messages=[
|
|
|
|
| 24 |
)
|
| 25 |
return response["choices"][0]["message"]["content"]
|
| 26 |
|
|
|
|
| 27 |
def main():
|
| 28 |
"""
|
| 29 |
+
Launch the Gradio interface for claim comparison.
|
| 30 |
"""
|
| 31 |
# Define the Gradio interface
|
| 32 |
interface = gr.Interface(
|
| 33 |
fn=compare_claims,
|
| 34 |
+
inputs=[
|
| 35 |
+
gr.Textbox(label="Claim 1", placeholder="Enter first claim description..."),
|
| 36 |
+
gr.Textbox(label="Claim 2", placeholder="Enter second claim description...")
|
| 37 |
+
],
|
| 38 |
+
outputs="text",
|
| 39 |
+
title="Claims Comparison",
|
| 40 |
+
description="Enter two claims to compare their differences."
|
| 41 |
)
|
| 42 |
|
| 43 |
# Launch the Gradio app
|
| 44 |
interface.launch()
|
| 45 |
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
main()
|