mirror of
https://github.com/run-llama/chat-ui.git
synced 2026-07-21 11:25:22 -04:00
fix: baseUrl should be optional for llama-deploy example (#139)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@llamaindex/chat-ui': patch
|
||||
---
|
||||
|
||||
fix: baseUrl should be optional for llama deploy
|
||||
@@ -3,19 +3,16 @@
|
||||
import { useState } from 'react'
|
||||
import { useWorkflow } from '@llamaindex/chat-ui'
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_BASE_PATH ?? ''
|
||||
const deployment = process.env.NEXT_PUBLIC_DEPLOYMENT_NAME || 'QuickStart'
|
||||
const defaultWorkflow =
|
||||
process.env.NEXT_PUBLIC_WORKFLOW_NAME || 'adhoc_workflow'
|
||||
const DEPLOYMENT_NAME = 'QuickStart'
|
||||
const DEFAULT_WORKFLOW = 'adhoc_workflow'
|
||||
|
||||
export default function Home() {
|
||||
const [userInput, setUserInput] = useState('Please run task')
|
||||
const [workflow, setWorkflow] = useState(defaultWorkflow)
|
||||
const [workflow, setWorkflow] = useState(DEFAULT_WORKFLOW)
|
||||
|
||||
const { runId, start, stop, sendEvent, events, status } = useWorkflow({
|
||||
baseUrl,
|
||||
deployment,
|
||||
workflow,
|
||||
deployment: DEPLOYMENT_NAME,
|
||||
workflow: DEFAULT_WORKFLOW,
|
||||
onStopEvent: event => {
|
||||
console.log('Stop event:', event)
|
||||
},
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { NextConfig } from 'next'
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
// The base path to create proxy to nextjs frontend in LlamaDeploy
|
||||
basePath: '/deployments/QuickStart/ui',
|
||||
}
|
||||
|
||||
export default nextConfig
|
||||
@@ -72,11 +72,7 @@ export async function fetchTaskEvents<E extends WorkflowEvent>(
|
||||
},
|
||||
callback?: StreamingEventCallback<E>
|
||||
): Promise<E[]> {
|
||||
const baseUrl = params.client.getConfig().baseUrl
|
||||
if (!baseUrl) {
|
||||
throw new Error('Base URL is missing in client config')
|
||||
}
|
||||
|
||||
const baseUrl = params.client.getConfig().baseUrl || ''
|
||||
const { task_id, session_id } = params.task
|
||||
const url = `${baseUrl}/deployments/${params.deploymentName}/tasks/${task_id}/events?session_id=${session_id}&raw_event=true`
|
||||
const response = await fetch(url, {
|
||||
|
||||
Reference in New Issue
Block a user