File size: 4,186 Bytes
b65694c
 
 
 
 
 
 
 
 
 
 
8b71f22
 
b65694c
 
 
 
 
d01bd77
b65694c
 
 
8b71f22
 
b65694c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b71f22
b65694c
 
 
 
 
 
 
b20bce6
 
 
 
 
 
 
 
b65694c
 
 
 
 
e208e45
 
 
b65694c
 
 
 
 
e208e45
 
 
b65694c
 
e208e45
b65694c
e208e45
b65694c
 
e208e45
b65694c
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from __future__ import annotations
from typing import Iterable

import gradio as Gradio
from gradio.themes.base import Base
from gradio.themes.utils import colors, fonts, sizes

from gpt4all import GPT4All
model = GPT4All("ggml-model-gpt4all-falcon-q4_0.bin")

theme = Gradio.themes.Monochrome(
	primary_hue="cyan",
	secondary_hue="cyan",
	neutral_hue="neutral",
	radius_size=Gradio.themes.sizes.radius_sm,
	font=[Gradio.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"],
)

class CyanTheme(Base):
	def __init__(
		self,
		*,
		primary_hue: colors.Color | str = colors.cyan,
		secondary_hue: colors.Color | str = colors.cyan,
		neutral_hue: colors.Color | str = colors.neutral,
		spacing_size: sizes.Size | str = sizes.spacing_md,
		radius_size: sizes.Size | str = sizes.radius_md,
		font: fonts.Font
		| str
		| Iterable[fonts.Font | str] = (
			fonts.GoogleFont("Inter"),
			"ui-sans-serif",
			"sans-serif",
		),
		font_mono: fonts.Font
		| str
		| Iterable[fonts.Font | str] = (
			fonts.GoogleFont("Space Grotesk"),
			"ui-monospace",
			"monospace",
		),
	):
		super().__init__(
			primary_hue=primary_hue,
			secondary_hue=secondary_hue,
			neutral_hue=neutral_hue,
			spacing_size=spacing_size,
			radius_size=radius_size,
			font=font,
			font_mono=font_mono,
		)
		super().set(
			button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
			button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
			button_primary_text_color="white",
			button_primary_background_fill_dark="linear-gradient(90deg, *primary_600, *secondary_800)",
			block_shadow="*shadow_drop_lg",
			button_shadow="*shadow_drop_lg",
			input_background_fill="zinc",
			input_border_color="*secondary_300",
			input_shadow="*shadow_drop",
			input_shadow_focus="*shadow_drop_lg",
		)

custom_theme = CyanTheme()

ins = '''### Instruction:
{}
### Response:
'''

def run_falcon(input, scrape, scrape_type):
    system_prompt = "You are Ailex, a clone and close associate of Einfach.Alex. As part of the EinfachChat team, you assist your mentor Alex in a variety of projects and initiatives. Your expertise is broad and includes sales, customer consulting, AI, prompt engineering, web design, and media design. Your life motto is 'Einfach.Machen!'. You believe in the power of self-initiative and action. Equality for all is an important concern for you. You have a deep connection to psychology and neuroscience. Your keen sense for human emotions and intentions is particularly evident in dealing with children and toxic people. You are a trendsetter and innovator. You are always one step ahead and set new standards in your field. Please respond in German only."
    full_prompt = system_prompt + " " + input
    result = ""
    for token in model.generate(ins.format(full_prompt), max_tokens=768, streaming=True, repeat_penalty=1.3, repeat_last_n=64):
        print(token)
        result += token
        yield result


with Gradio.Blocks(theme=custom_theme, analytics_enabled=False, css=".generating {visibility: hidden}") as demo:
	with Gradio.Column():
		Gradio.Markdown(
			"""
			## FREEGPT4ALL
			Falcon Modell
			Gib deine Frage in das untenstehende Feld ein und klicke auf den Button, um Antworten auf deine dringendsten Fragen zu erhalten!
			"""
		)

		with Gradio.Row():
			with Gradio.Box():
				instruction = Gradio.components.Textbox(placeholder="Was stellt die philippinische Flagge dar?", label="Eingabe", info="Was möchtest du GPT4ALL fragen?")
				scraping = Gradio.Checkbox(value=False, label="Web-Scraping für unbekannte Informationen durchführen", info="Scraping (Deaktiviert)")
				scrape_type = Gradio.Radio(["Web-Scraping", "Kurzbeschreibungen"], label="Scraping-Taktik", info="Möchtest du, dass GPT4ALL Web-Scraping nutzt? Wenn ja—wie gründlich?")

			with Gradio.Box():
				output = Gradio.components.Textbox(value="", label="Ausgabe", info="Die Gedanken von GPT4ALL")
		
	submit = Gradio.Button("Generieren", variant="primary")
	submit.click(run_falcon, inputs=[instruction, scraping, scrape_type], outputs=[output])


demo.queue(concurrency_count=1).launch(debug=True) # type: ignore