mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
feat: just more cleaning
This commit is contained in:
parent
46cef4b7fa
commit
4b4b4d47bc
24 changed files with 2852 additions and 829 deletions
|
|
@ -2,14 +2,10 @@ import { useEffect, useRef, useState } from 'react'
|
|||
|
||||
import type { CompletionItem } from '../app/interfaces.js'
|
||||
import type { GatewayClient } from '../gatewayClient.js'
|
||||
|
||||
import type { CompletionResponse } from '../gatewayTypes.js'
|
||||
import { asRpcResult } from '../lib/rpc.js'
|
||||
const TAB_PATH_RE = /((?:["']?(?:[A-Za-z]:[\\/]|\.{1,2}\/|~\/|\/|@|[^"'`\s]+\/))[^\s]*)$/
|
||||
|
||||
interface CompletionResult {
|
||||
items?: CompletionItem[]
|
||||
replace_from?: number
|
||||
}
|
||||
|
||||
export function useCompletion(input: string, blocked: boolean, gw: GatewayClient) {
|
||||
const [completions, setCompletions] = useState<CompletionItem[]>([])
|
||||
const [compIdx, setCompIdx] = useState(0)
|
||||
|
|
@ -51,12 +47,12 @@ export function useCompletion(input: string, blocked: boolean, gw: GatewayClient
|
|||
}
|
||||
|
||||
const req = isSlash
|
||||
? gw.request('complete.slash', { text: input })
|
||||
: gw.request('complete.path', { word: pathWord })
|
||||
? gw.request<CompletionResponse>('complete.slash', { text: input })
|
||||
: gw.request<CompletionResponse>('complete.path', { word: pathWord })
|
||||
|
||||
req
|
||||
.then(raw => {
|
||||
const r = raw as CompletionResult | null | undefined
|
||||
const r = asRpcResult<CompletionResponse>(raw)
|
||||
|
||||
if (ref.current !== input) {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue