InnovTech commited on
Commit
be7ab52
·
1 Parent(s): 23cbdb6

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +112 -0
app.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+ from typing import Iterable
3
+ import gradio as gr
4
+ from gradio.themes.base import Base
5
+ from gradio.themes.utils import colors, fonts, sizes
6
+
7
+ from llama_cpp import Llama
8
+ #from huggingface_hub import hf_hub_download
9
+
10
+ #hf_hub_download(repo_id="LLukas22/gpt4all-lora-quantized-ggjt", filename="ggjt-model.bin", local_dir=".")
11
+ llm = Llama(model_path="./ggjt-model.bin")
12
+
13
+
14
+ ins = '''### Instruction:
15
+ {}
16
+ ### Response:
17
+ '''
18
+
19
+ theme = gr.themes.Monochrome(
20
+ primary_hue="indigo",
21
+ secondary_hue="blue",
22
+ neutral_hue="slate",
23
+ radius_size=gr.themes.sizes.radius_sm,
24
+ font=[gr.themes.GoogleFont("Open Sans"), "ui-sans-serif", "system-ui", "sans-serif"],
25
+ )
26
+
27
+
28
+
29
+
30
+
31
+
32
+ # Based on the gradio theming guide and borrowed from https://huggingface.co/spaces/shivi/dolly-v2-demo
33
+ class SeafoamCustom(Base):
34
+ def __init__(
35
+ self,
36
+ *,
37
+ primary_hue: colors.Color | str = colors.emerald,
38
+ secondary_hue: colors.Color | str = colors.blue,
39
+ neutral_hue: colors.Color | str = colors.blue,
40
+ spacing_size: sizes.Size | str = sizes.spacing_md,
41
+ radius_size: sizes.Size | str = sizes.radius_md,
42
+ font: fonts.Font
43
+ | str
44
+ | Iterable[fonts.Font | str] = (
45
+ fonts.GoogleFont("Quicksand"),
46
+ "ui-sans-serif",
47
+ "sans-serif",
48
+ ),
49
+ font_mono: fonts.Font
50
+ | str
51
+ | Iterable[fonts.Font | str] = (
52
+ fonts.GoogleFont("IBM Plex Mono"),
53
+ "ui-monospace",
54
+ "monospace",
55
+ ),
56
+ ):
57
+ super().__init__(
58
+ primary_hue=primary_hue,
59
+ secondary_hue=secondary_hue,
60
+ neutral_hue=neutral_hue,
61
+ spacing_size=spacing_size,
62
+ radius_size=radius_size,
63
+ font=font,
64
+ font_mono=font_mono,
65
+ )
66
+ super().set(
67
+ button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
68
+ button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
69
+ button_primary_text_color="white",
70
+ button_primary_background_fill_dark="linear-gradient(90deg, *primary_600, *secondary_800)",
71
+ block_shadow="*shadow_drop_lg",
72
+ button_shadow="*shadow_drop_lg",
73
+ input_background_fill="zinc",
74
+ input_border_color="*secondary_300",
75
+ input_shadow="*shadow_drop",
76
+ input_shadow_focus="*shadow_drop_lg",
77
+ )
78
+
79
+
80
+ seafoam = SeafoamCustom()
81
+
82
+
83
+ with gr.Blocks(theme=seafoam, analytics_enabled=False, css=css) as demo:
84
+ with gr.Column():
85
+ gr.Markdown(
86
+ """ ## Innovtech Pro AI
87
+
88
+ """
89
+ )
90
+
91
+ with gr.Row():
92
+ with gr.Column(scale=3):
93
+ instruction = gr.Textbox(placeholder="Enter your question here", label="Question", elem_id="q-input")
94
+
95
+ with gr.Box():
96
+ gr.Markdown("**Answer**")
97
+ output = gr.Markdown(elem_id="q-output")
98
+ submit = gr.Button("Generate", variant="primary")
99
+ gr.Examples(
100
+ examples=examples,
101
+ inputs=[instruction],
102
+ cache_examples=False,
103
+ fn=process_example,
104
+ outputs=[output],
105
+ )
106
+
107
+
108
+
109
+ submit.click(generate, inputs=[instruction], outputs=[output])
110
+ instruction.submit(generate, inputs=[instruction], outputs=[output])
111
+
112
+ demo.queue(concurrency_count=1).launch(debug=True)