Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2.0
- #SingleInstance Force
- OllamaGui := Gui(, "Ollama API")
- OllamaGui.Add("Text", "x10 y14 w60 h14", "Prompt")
- OllamaGui.Add("Text", "x100 y14 w200 h14", "Ctrl+Enter=New Line | Enter=Send")
- Prompt_Edit := OllamaGui.Add("Edit", "x10 y30 w420 h125 -WantReturn +Multi", "How does one go about shop until you drop?")
- OllamaGui.Add("Text", "x10 y164 w60 h14", "Response")
- Response_Edit := OllamaGui.Add("Edit", "x10 y180 w420 h175 +Multi")
- OllamaGui.Add("Text", "x10 y364 w60 h14", "Model")
- Model_Edit := OllamaGui.Add("Edit", "x10 y380 w130 h30 -vScroll r1", "dolphin-mistral:latest")
- OllamaGui.Add("Text", "x150 y364 w60 h14", "Context")
- Context_Edit := OllamaGui.Add("Edit", "x150 y380 w130 h30 -vScroll r1", "2000")
- OllamaGui.Add("Text", "x300 y364 w60 h14", "Temperature")
- Temperature_Edit := OllamaGui.Add("Edit", "x300 y380 w130 h30 -vScroll r1", "0.8")
- H_SendRequest := OllamaGui.AddButton("Default Hidden", "OK")
- H_SendRequest.OnEvent("Click", SendRequest)
- OllamaGui.Show("w440 h420")
- SendRequest(*)
- {
- DATA := "
- (
- {
- "model": "Model_EditValueC",
- "prompt": "Prompt_EditValueC",
- "stream": false,
- "Options": {
- "temperature": "Temperature_EditValueC",
- "num_ctx": "Context_EditValueC"
- }
- }
- )"
- ; Is this the (Can't be) best way to variable the above like below, instead of making every escape?
- DATA := StrReplace(DATA, "`"Context_EditValueC`"", Context_Edit.Value)
- DATA := StrReplace(DATA, "`"Temperature_EditValueC`"", Temperature_Edit.Value)
- DATA := StrReplace(DATA, "`"Prompt_EditValueC`"", "`"" Prompt_Edit.Value "`"")
- DATA := StrReplace(DATA, "`"Model_EditValueC`"", "`"" Model_Edit.Value "`"")
- URL := "http://localhost:11434/api/generate"
- WinHttp := ComObject("WinHttp.WinHttpRequest.5.1")
- WinHttp.Open("POST", URL, True)
- WinHttp.SetRequestHeader("Content-Type", "application/json")
- WinHttp.Send(DATA)
- WinHttp.WaitForResponse
- DATA := WinHttp.ResponseText
- RegExMatch(DATA, "s)(?<=`",`"response`":`").*?(?=`",`"done`":true)", &Match)
- DATA := Match[0]
- DATA := StrReplace(DATA, "\`"", "`"")
- DATA := StrReplace(DATA, "\n", "`n")
- Response_Edit.Value := DATA
- }
- Numpad2::
- {
- Reload
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement