Spaces:
Sleeping
Sleeping
File size: 2,620 Bytes
1c2c598 8cad5e4 1c2c598 8cad5e4 1c2c598 8cad5e4 1c2c598 8cad5e4 e4ddcc0 8cad5e4 194b408 8cad5e4 194b408 8cad5e4 194b408 1c2c598 e4ddcc0 1c2c598 8cad5e4 1c2c598 8cad5e4 1c2c598 8cad5e4 1c2c598 93dacff 8cad5e4 194b408 8cad5e4 1c2c598 5431ba3 e4ddcc0 8cad5e4 1c2c598 8cad5e4 93dacff 8cad5e4 c14fc1b 1c2c598 93dacff |
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import openai
import random
import gradio as gr
import os
openai.api_key = os.environ["OpenAPI_Key"]
manual = r"""Vul beide velden in door titel en course tree te kopiëren vanuit de Factsheet in MES Editor, en druk op Submit."""
# Define the system message
SystemPrompt_10 = r"""You're a factsheets creator: creating factsheets for our e-learning modules that comply precisely with the requirements. The user will send as input:
1. Title of e-learning
2. Course structure
You will convert this info into a factsheet, with the following components:
-Description:
[Catchy text with a short explanation what the module is about(75 - 100 words, a few sentences), in Dutch.Use language like: 'In deze module bespreken we ...'.]
-Competencies:
f.Competences: Select the competences, related to this course from the list below and should not exceed 3:
1.Vakinhoudelijk / Klinisch handelen
2. Communicatie
3. Samenwerking
4. Organisatie
5. Maatschappelijk handelen
6. Kennis en wetenschap
7. Professionaliteit
Please add the respective percentage for each competence. Use % that are only multiples of 10, e.g. 10%, 20% and so on, and not 15%, 25% and so on. Naturally, the sum of all should be 100%.
Just give your best estimate.
- Target group(s)
[pick one from: Onderwijsassistent / Persoonlijk Begeleider MZ / Gespecialiseerd pedagogisch medewerker. If none of those qualify, make up your own.]"""
UserPrompt_10 = r""""""
AssistantPrompt_10 = r""""""
UserPrompt_11 = r""""""
AssistantPrompt_11 = r""""""
# Function to make API call
def api_call(messages, temperature=0.5, model="gpt-4"):
return openai.ChatCompletion.create(
messages=messages,
temperature=temperature,
model=model
).choices[0].message.content
# Function to be called by Gradio interface
def process_inputs(Name, Tree):
# Check if either field is empty
if not Name:
return manual
if not Tree:
return manual
else:
# Step 1: User input and first API call
stepOne = [
{"role": "system", "content": SystemPrompt_10},
{"role": "user", "content": f"Title of e-learning: {Name}\n\nCourse structure:\n{Tree}"}
]
Script_1 = api_call(stepOne, 0.7)
return Script_1
# Create the Gradio interface
iface = gr.Interface(
fn=process_inputs,
inputs=[
gr.Textbox(lines=2, label='Name of e-learning'),
gr.Textbox(lines=2, label='Course Structure')
],
outputs=gr.Textbox(label="Suggested Factsheet info (double-check & revise)", show_copy_button=True)
)
iface.launch(share=True)
iface.launch() |