Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
f6f8f528
Commit
f6f8f528
authored
Jun 24, 2023
by
Jeffrey Morgan
Browse files
Add placeholder image; connect to server
parent
5142ba2d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
19 deletions
+34
-19
client/forge.config.ts
client/forge.config.ts
+1
-0
client/images/icon.icns
client/images/icon.icns
+0
-0
client/src/app.css
client/src/app.css
+1
-1
client/src/app.tsx
client/src/app.tsx
+32
-15
client/src/index.ts
client/src/index.ts
+0
-3
No files found.
client/forge.config.ts
View file @
f6f8f528
...
...
@@ -12,6 +12,7 @@ import { rendererConfig } from './webpack.renderer.config'
const
config
:
ForgeConfig
=
{
packagerConfig
:
{
asar
:
true
,
icon
:
'
./images/icon
'
,
},
rebuildConfig
:
{},
makers
:
[
new
MakerSquirrel
({}),
new
MakerZIP
({},
[
'
darwin
'
]),
new
MakerRpm
({}),
new
MakerDeb
({})],
...
...
client/images/icon.icns
0 → 100644
View file @
f6f8f528
File added
client/src/app.css
View file @
f6f8f528
...
...
@@ -8,5 +8,5 @@ body {
}
.drag
{
-webkit-app-region
:
d
e
ag
;
-webkit-app-region
:
d
r
ag
;
}
client/src/app.tsx
View file @
f6f8f528
import
{
useState
}
from
'
react
'
const
API_URL
=
'
http://127.0.0.1:
808
0
'
const
API_URL
=
'
http://127.0.0.1:
500
0
'
type
Message
=
{
sender
:
string
...
...
@@ -8,16 +8,18 @@ type Message = {
}
async
function
completion
(
prompt
:
string
,
callback
:
(
res
:
string
)
=>
void
)
{
const
result
=
await
fetch
(
`
${
API_URL
}
/
completion
`
,
{
const
result
=
await
fetch
(
`
${
API_URL
}
/
generate
`
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
({
prompt
:
prompt
,
temperature
:
0.2
,
top_k
:
40
,
top_p
:
0.9
,
n_predict
:
256
,
stop
:
[
'
\n
### Human:
'
],
// stop completion after generating this
stream
:
true
,
prompt
:
`A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.
### Human: Hello, Assistant.
### Assistant: Hello. How may I help you today?
### Human:
${
prompt
}
`
,
model
:
'
ggml-model-q4_0
'
,
}),
})
...
...
@@ -36,12 +38,17 @@ async function completion(prompt: string, callback: (res: string) => void) {
let
decoder
=
new
TextDecoder
()
let
str
=
decoder
.
decode
(
value
)
if
(
str
.
startsWith
(
'
data:
'
))
{
const
message
=
JSON
.
parse
(
str
.
substring
(
6
))
callback
(
message
.
content
)
if
(
message
.
stop
)
{
let
re
=
/}{/g
str
=
'
[
'
+
str
.
replace
(
re
,
'
},{
'
)
+
'
]
'
let
messages
=
JSON
.
parse
(
str
)
for
(
const
message
of
messages
)
{
const
choice
=
message
.
choices
[
0
]
if
(
choice
.
finish_reason
===
'
stop
'
)
{
break
}
callback
(
choice
.
text
)
}
}
...
...
@@ -63,10 +70,20 @@ export default function () {
<
section
className
=
'mx-auto mb-10 w-full max-w-xl flex-1 break-words'
>
{
messages
.
map
((
m
,
i
)
=>
(
<
div
className
=
'my-4 flex gap-4'
key
=
{
i
}
>
<
div
className
=
'flex-none pr-1 text-lg'
>
{
m
.
sender
===
'
human
'
?
'
👩
'
:
'
🤖
'
}
</
div
>
<
div
className
=
'flex-none pr-1 text-lg'
>
{
m
.
sender
===
'
human
'
?
(
<
div
className
=
'bg-neutral-200 text-neutral-700 text-sm h-6 w-6 rounded-md flex items-center justify-center mt-px'
>
H
</
div
>
)
:
(
<
div
className
=
'bg-blue-600 text-white text-sm h-6 w-6 rounded-md flex items-center justify-center mt-0.5'
>
L
</
div
>
)
}
</
div
>
<
div
className
=
'flex-1 text-gray-800'
>
{
m
.
content
}
{
m
.
sender
===
'
bot
'
&&
<
span
className
=
'relative -top-[3px] left-1 text-[10px]
text-blue-600
'
>
⬤
</
span
>
}
{
m
.
sender
===
'
bot
'
&&
<
span
className
=
'relative -top-[3px] left-1 text-[10px]'
>
⬤
</
span
>
}
</
div
>
</
div
>
))
}
...
...
client/src/index.ts
View file @
f6f8f528
...
...
@@ -39,9 +39,6 @@ const createWindow = (): void => {
// and load the index.html of the app.
mainWindow
.
loadURL
(
MAIN_WINDOW_WEBPACK_ENTRY
)
// Open the DevTools.
mainWindow
.
webContents
.
openDevTools
()
}
// This method will be called when Electron has finished
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment