This commit is contained in:
Henri Vasserman 2023-06-12 18:43:40 +03:00
parent 1510337901
commit fc4264d14a
No known key found for this signature in database
GPG key ID: 2995FC0F58B1A986

View file

@ -1,6 +1,8 @@
import * as readline from 'node:readline' import * as readline from 'node:readline'
import { stdin, stdout } from 'node:process' import { stdin, stdout } from 'node:process'
const API_URL = 'http://127.0.0.1:8080'
const chat = [ const chat = [
{ {
human: "Hello, Assistant.", human: "Hello, Assistant.",
@ -21,7 +23,7 @@ function format_prompt(question) {
} }
async function tokenize(content) { async function tokenize(content) {
const result = await fetch("http://127.0.0.1:8080/tokenize", { const result = await fetch(`${API_URL}/tokenize`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ content }) body: JSON.stringify({ content })
}) })
@ -36,7 +38,7 @@ async function tokenize(content) {
const n_keep = await tokenize(instruction).length const n_keep = await tokenize(instruction).length
async function chat_completion(question) { async function chat_completion(question) {
const result = await fetch("http://127.0.0.1:8080/completion", { const result = await fetch(`${API_URL}/completion`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
prompt: format_prompt(question), prompt: format_prompt(question),