AraEmail / app.py
saadalafalcon's picture
Update app.py
38a2f84 verified
raw
history blame contribute delete
No virus
2.67 kB
# -*- coding: utf-8 -*-
"""GPT3.5 (AraMail) b5shm_alriyal.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/188Zgvg152MTpUdJqYxrPYWHLN1lVNgqR
"""
import openai
# Set your OpenAI API key
openai.api_key = "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"
# Function to generate a concise explanation story using GPT-3
def generate_concise_explanation_story(prompt):
# Define a concise prompt for GPT-3
# Use GPT-3 to generate a concise explanation
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": """Act as an formal arabic generator, the user will ask you about a
specific subject and you will generate a formal arabic email based on the subject.
this is an example for the structure that you will generate: الموضوع: طلب استفسار
السيد/السيدة [الاسم الكامل],
أتمنى أن تكون بأتم الصحة والعافية.
أود أن أطلب من حضرتكم إعطائي مزيد من المعلومات حول [الموضوع الذي تود الاستفسار عنه]. وأود أيضاً الاطلاع على [المستندات/المعلومات الإضافية] التي قد تكون مفيدة في هذا السياق.
أشكر لكم تعاونكم وجهودكم المبذولة في تقديم المساعدة. لا تترددوا في الاتصال بي إذا كانت هناك أي أسئلة إضافية.
شكراً لحسن تعاونكم.
حفظكم الله،
[الاسم الكامل]
[المسمى الوظيفي]
[رقم الهاتف]
[البريد الإلكتروني]
"""
},
{"role": "user", "content": prompt}
]
)
#concise_explanation = response['choices'][0]['message']['content'].strip()
concise_explanation = response.choices[0].message['content']
return concise_explanation
import gradio as gr
iface = gr.Interface(
fn=generate_concise_explanation_story,
inputs=gr.components.Textbox(lines=2, placeholder="Type your request here..."),
outputs=gr.components.Textbox(label="Generated Email"),
title="AraMail_v3.0",
description='''
Generates an official email based on the provided subject and order. Example prompt:
'اكتب لي ايميل رد عرض راتب والتفاوض عليه',
'اكتبلي ايميل طلب توظيف لمسمى مهندس ذكاء اصطناعي
,اكتب لي ايميل طلب بيانات من ادارة المالية'
'''
)
# Run the interface
iface.launch(share=True)