Spaces:
Sleeping
Sleeping
Synced repo using 'sync_with_huggingface' Github Action
Browse files
app.py
CHANGED
@@ -22,57 +22,62 @@ with st.sidebar:
|
|
22 |
<style>
|
23 |
[data-testid=stImage]{
|
24 |
display: block;
|
|
|
25 |
margin-left: auto;
|
26 |
margin-right: auto;
|
27 |
-
padding-bottom: 40px;
|
28 |
}
|
29 |
</style>
|
30 |
""", unsafe_allow_html=True)
|
31 |
st.image(image="olive_farm.png", width=100)
|
32 |
|
33 |
st.markdown("""
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
""", unsafe_allow_html=True)
|
41 |
-
|
42 |
-
It's designed to effortlessly generate LLM (Language Model) instruction sets in Indic languages.
|
43 |
-
Presently, it offers support for Hindi and Odia, with seamless scalability to incorporate additional
|
44 |
-
languages on the horizon.""")
|
45 |
-
st.markdown(
|
46 |
-
"""
|
47 |
-
This versatile tool accommodates inputs from a variety of sources, including:
|
48 |
-
- URLs,
|
49 |
-
- PDF documents,
|
50 |
-
- Plain text.
|
51 |
-
"""
|
52 |
-
)
|
53 |
-
st.markdown("""
|
54 |
-
Additionally, OliveFarm features a collection of pre-existing templates, powered by ChatGPT,
|
55 |
-
to streamline the process of generating instruction sets. Experience the future of Indic
|
56 |
-
language instruction with OliveFarm!
|
57 |
-
|
58 |
-
Contributors:
|
59 |
-
- AR Kamaldeen (KIIT University, India)
|
60 |
-
- SK Shahid (Silicon Institute of Technology, India)
|
61 |
-
- Sambit Sekhar (Odia Generative AI, India)
|
62 |
-
- Dr. Shantipriya Parida (Silo AI, Finland)
|
63 |
-
|
64 |
-
""")
|
65 |
-
st.write("#")
|
66 |
st.markdown(
|
67 |
"""
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
76 |
"""
|
77 |
, unsafe_allow_html=True)
|
78 |
|
@@ -340,35 +345,37 @@ def main():
|
|
340 |
- You must return the response in the specified language.
|
341 |
- Each generated instruction can be either an imperative sentence or a question.
|
342 |
"""
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
|
|
|
|
369 |
if st.session_state.generated:
|
370 |
# displaying the generated instructions
|
371 |
-
st.write("Generated
|
372 |
result = st.session_state["result"]
|
373 |
# print(type(result))
|
374 |
# print(result)
|
@@ -410,40 +417,42 @@ def main():
|
|
410 |
"""
|
411 |
|
412 |
question = st.session_state["selected_items"]
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
#
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
|
|
|
|
447 |
if st.session_state.answered:
|
448 |
# displaying the generated Answers
|
449 |
|
@@ -457,12 +466,12 @@ def main():
|
|
457 |
# print(answers_dict)
|
458 |
# print("Checked point 4!")
|
459 |
# st.write("answers")
|
460 |
-
st.write(answers_dict)
|
461 |
|
462 |
# Create a list to hold the JSON-like data
|
463 |
st.write("Generated Questions and Answers")
|
464 |
# Create a list of dictionaries
|
465 |
-
jsonl_data = [{"
|
466 |
|
467 |
|
468 |
st.write(jsonl_data)
|
@@ -500,7 +509,7 @@ def main():
|
|
500 |
del st.session_state["result"]
|
501 |
if "selected_items" in st.session_state:
|
502 |
del st.session_state["selected_items"]
|
503 |
-
if "
|
504 |
del st.session_state["answers"]
|
505 |
st.experimental_rerun()
|
506 |
|
|
|
22 |
<style>
|
23 |
[data-testid=stImage]{
|
24 |
display: block;
|
25 |
+
margin-top: -20px;
|
26 |
margin-left: auto;
|
27 |
margin-right: auto;
|
|
|
28 |
}
|
29 |
</style>
|
30 |
""", unsafe_allow_html=True)
|
31 |
st.image(image="olive_farm.png", width=100)
|
32 |
|
33 |
st.markdown("""
|
34 |
+
<style>
|
35 |
+
.sidebar-text {
|
36 |
+
text-align: justify;
|
37 |
+
font-size: 14px;
|
38 |
+
padding-bottom: 16px;
|
39 |
+
}
|
40 |
+
.list {
|
41 |
+
font-size: 14px !important;
|
42 |
+
}
|
43 |
+
|
44 |
+
</style>
|
45 |
+
<div class="sidebar-text">
|
46 |
+
OliveFarm is a cutting-edge web application crafted by the innovative minds at OdiaGenAI.
|
47 |
+
It's designed to effortlessly generate LLM (Language Model) instruction sets in Indic languages.
|
48 |
+
Presently, it offers support for Hindi and Odia, with seamless scalability to incorporate
|
49 |
+
additional languages on the horizon.
|
50 |
+
</div>
|
51 |
+
<div class="sidebar-text">
|
52 |
+
This versatile tool accommodates inputs from a variety of sources, including (URLs, PDF documents, and plain text).
|
53 |
+
</div>
|
54 |
+
<div class="sidebar-text">
|
55 |
+
Additionally, OliveFarm features a collection of pre-existing templates, powered by ChatGPT,
|
56 |
+
to streamline the process of generating instruction sets. Experience the future of
|
57 |
+
Indic language instruction with OliveFarm!
|
58 |
+
</div>
|
59 |
+
<div class="sidebar-text">
|
60 |
+
Contributors:
|
61 |
+
</div>
|
62 |
+
<ul>
|
63 |
+
<li class="list">AR Kamaldeen</li>
|
64 |
+
<li class="list">SK Shahid</li>
|
65 |
+
<li class="list">Sambit Sekhar</li>
|
66 |
+
<li class="list">Dr. Shantipriya Parida</li>
|
67 |
+
</ul>
|
68 |
""", unsafe_allow_html=True)
|
69 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
st.markdown(
|
71 |
"""
|
72 |
+
<style>
|
73 |
+
.copyright {
|
74 |
+
text-align: center;
|
75 |
+
font-size: 14px;
|
76 |
+
}
|
77 |
+
</style>
|
78 |
+
<div class="copyright">
|
79 |
+
© 2023 Odia Generative AI
|
80 |
+
</div>
|
81 |
"""
|
82 |
, unsafe_allow_html=True)
|
83 |
|
|
|
345 |
- You must return the response in the specified language.
|
346 |
- Each generated instruction can be either an imperative sentence or a question.
|
347 |
"""
|
348 |
+
try :
|
349 |
+
if st.button("Generate Instructions"):
|
350 |
+
prompt = my_prompt_template.format(
|
351 |
+
num_questions=noOfQuestions,
|
352 |
+
context=extractedData,
|
353 |
+
instruction_format=instructionFormat,
|
354 |
+
lang=language,
|
355 |
+
additional_rules=additional_rules
|
356 |
+
)
|
357 |
+
response = openai.ChatCompletion.create(
|
358 |
+
model="gpt-3.5-turbo",
|
359 |
+
messages=[
|
360 |
+
{"role": "system", "content": prompt},
|
361 |
+
])
|
362 |
+
# if st.button("Generate Instructions"):
|
363 |
+
print("Generate button")
|
364 |
+
print("Checkpoint 1!")
|
365 |
+
|
366 |
+
if "result" not in st.session_state:
|
367 |
+
content = response.choices[0].message.content
|
368 |
+
# content = "\n1. helloworld1.\n2. helloworld2"
|
369 |
+
responses_list = content.split('\n')
|
370 |
+
responses_list = [re.sub(r'^\s*\d+\.\s*', '', resp) for resp in responses_list if resp]
|
371 |
+
st.session_state["result"]=responses_list
|
372 |
+
st.session_state.generated = True
|
373 |
+
st.session_state.Initial = False
|
374 |
+
except Exception as err:
|
375 |
+
st.error(err)
|
376 |
if st.session_state.generated:
|
377 |
# displaying the generated instructions
|
378 |
+
st.write("Generated Instructions")
|
379 |
result = st.session_state["result"]
|
380 |
# print(type(result))
|
381 |
# print(result)
|
|
|
417 |
"""
|
418 |
|
419 |
question = st.session_state["selected_items"]
|
420 |
+
try:
|
421 |
+
if st.button("Generate Answers"):
|
422 |
+
prompt = my_prompt_template2.format(
|
423 |
+
questions=question,
|
424 |
+
additional_rules = additional_rules
|
425 |
+
)
|
426 |
+
response = openai.ChatCompletion.create(
|
427 |
+
model="gpt-3.5-turbo",
|
428 |
+
messages=[
|
429 |
+
{"role": "system", "content": prompt},
|
430 |
+
])
|
431 |
+
|
432 |
+
# if st.button("Generate Answers"):
|
433 |
+
# print("\n\n\n\nInside Answersss:\n\n\n\n")
|
434 |
+
# print(st.session_state["selected_items"])
|
435 |
+
|
436 |
+
# print("Generate button")
|
437 |
+
# print("Checkpoint 3!")
|
438 |
+
|
439 |
+
if "answers" not in st.session_state:
|
440 |
+
content = response.choices[0].message.content
|
441 |
+
# content = "\n1. Answer1.\n2. Answer2"
|
442 |
+
print("\n\n\n\n\nAnswerss before regex\n\n\n\n")
|
443 |
+
print(content)
|
444 |
+
# print("Answer Type:" + str(type(content)))
|
445 |
+
responses_list = content.split('\n')
|
446 |
+
# print("\n\n\n\n\nAnswerss before regex after splitting\n\n\n\n")
|
447 |
+
# print(responses_list)
|
448 |
+
# print("Answer Type:" + str(type(responses_list)))
|
449 |
+
|
450 |
+
responses_list = [re.sub(r'^\s*\d+\.\s*', '', resp) for resp in responses_list if resp]
|
451 |
+
st.session_state["answers"]=responses_list
|
452 |
+
st.session_state.answered = True
|
453 |
+
st.session_state.Initial2 = False
|
454 |
+
except Exception as e:
|
455 |
+
st.error(e)
|
456 |
if st.session_state.answered:
|
457 |
# displaying the generated Answers
|
458 |
|
|
|
466 |
# print(answers_dict)
|
467 |
# print("Checked point 4!")
|
468 |
# st.write("answers")
|
469 |
+
# st.write(answers_dict)
|
470 |
|
471 |
# Create a list to hold the JSON-like data
|
472 |
st.write("Generated Questions and Answers")
|
473 |
# Create a list of dictionaries
|
474 |
+
jsonl_data = [{"Instruction": question, "Output": answers_dict.get(i, 'No answer found'), "Input":""} for i, question in enumerate(questions, start=1)]
|
475 |
|
476 |
|
477 |
st.write(jsonl_data)
|
|
|
509 |
del st.session_state["result"]
|
510 |
if "selected_items" in st.session_state:
|
511 |
del st.session_state["selected_items"]
|
512 |
+
if "answers" in st.session_state:
|
513 |
del st.session_state["answers"]
|
514 |
st.experimental_rerun()
|
515 |
|