File size: 1,827 Bytes
c7fa0aa
5ddfe7e
 
c7fa0aa
9bb4c09
 
 
 
 
 
 
 
 
 
 
409328a
6f7f98a
9bb4c09
 
c7fa0aa
5ddfe7e
 
 
 
 
 
c7fa0aa
fa9bc9f
e65d26a
fa9bc9f
5ddfe7e
 
 
 
d9e6b75
 
6f7f98a
 
 
 
d9e6b75
 
 
9bb4c09
d9e6b75
c7fa0aa
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
import gradio as gr
from qdrant import qdrant_manager
from openai_manager import openai_manager

description = """
In this project, Im using Few-Shot Learning as an alternative to Fine-Tuning and Prompt 
Engineering methods. While Prompt Engineering offers a cost-effective and swift approach 
for development, it falls short in providing a comprehensive level of instruction 
definition. For instance, crafting instructions that simulate a specific writing style proves to be exceptionally challenging.
On the other hand, Fine-Tuning excels in terms of instruction integration as it 
comprehends and learns instructions rather than merely receiving them. However, it 
comes with challenges such as complexity, high costs, and time-intensive processes.
Few-Shot Learning elegantly positions itself between these two approaches, offering the 
best of both worlds. It provides an enticing balance that you might want to explore.
Why not give it a try?

This model works by providing a set of keywords separated by "," and It will return a Sales script To train you employees for different senarios.
"""


def generate(keywords):
    try:
        keywords_list = list(map(lambda x: x.strip(), keywords.split(",")))
    except:
        keywords_list = []
        gr.Warning("Please use ',' to separate Keywords")

    embedding = openai_manager.get_embedding(" ".join(keywords_list))

    points = qdrant_manager.search_point(query_vector=embedding)

    return openai_manager.shots(points, " ".join(keywords_list))


iface = gr.Interface(
    fn=generate,
    examples=[
        " Technology, Products, Returns, Warranty",
        " Energy, Warranty, Customer Service, Refund",
    ],
    inputs="text",
    outputs="text",
    title="Sales Role Play Generator - Few Shots Learning",
    description=description,
)
iface.launch()