Skip to content

Commit

Permalink
chore: disable zod validation for integration testing
Browse files Browse the repository at this point in the history
  • Loading branch information
yg-lim committed Aug 7, 2024
1 parent 0b1f376 commit 635da1c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 72 deletions.
64 changes: 41 additions & 23 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pipeline/config_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def ui_to_pipeline(ui_json):
},
'generative_model': ui_obj['generative_model'],
'prompt': {
'on': 'True' if ui_obj.get('prompt') else 'False',
'on': ui_obj.get('prompt', False),
'template_str': ui_obj.get('prompt', '')
}
}
Expand Down
4 changes: 2 additions & 2 deletions routers/chatbots.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def get_chatbots():
log.info('/api/chatbots loaded')
results = mutil.get_all(CONFIG_DB, CONFIG_PIPELINE_COL, {}, { '_id': 0 })
log.info('/api/chatbots results:', results)
return json.dumps(results)
return results

@router.get('/{id}')
async def get_chatbots_id(id: str):
Expand All @@ -38,7 +38,7 @@ async def get_chatbots_id(id: str):
if not results:
return json.dumps({"message": "no chatbot configuration found"})

return json.dumps(results)
return results

@router.post('/')
async def post_chatbots(request: Request):
Expand Down
48 changes: 5 additions & 43 deletions ui/src/services/chatbot-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,57 +50,19 @@ export type ServerPipelineConfig = z.infer<typeof serverPipelineConfigSchema>;

async function updateChatbot(id: string, data: ClientPipelineConfig) {
const response = await axios.put(`${baseUrl}/api/chatbots/${id}`, data);
return serverPipelineConfigSchema.parse(JSON.parse(response.data));
return response.data;
}

async function fetchChatbots() {
const response = await axios.get(`${baseUrl}/api/chatbots`);
const chatbots = serverPipelinesConfigSchema.parse(JSON.parse(response.data));
const clientChatbots: ClientPipelineConfig[] = chatbots.map((chatbot) => ({
id: chatbot.id,
name: chatbot.name,
knowledge_bases: chatbot.knowledgebases,
generative_model: chatbot.generative_model,
similarity: {
on: chatbot.postprocessing.similarity.on === "True",
cutoff: chatbot.postprocessing.similarity.cutoff,
},
colbert_rerank: {
on: chatbot.postprocessing.colbertRerank.on === "True",
top_n: chatbot.postprocessing.colbertRerank.top_n,
},
long_context_reorder: {
on: chatbot.postprocessing.longContextReorder.on === "True",
},
prompt: "",
}));
return clientChatbots;
console.log(response.data);
return response.data;
}

async function fetchChatbotById(id: string) {
const response = await axios.get(`${baseUrl}/api/chatbots/${id}`);
const chatbot = serverPipelineConfigSchema.parse(JSON.parse(response.data));
console.log(chatbot);
const clientChatbot: ClientPipelineConfig = {
id: chatbot.id,
name: chatbot.name,
knowledge_bases: chatbot.knowledgebases,
generative_model: chatbot.generative_model,
similarity: {
on: chatbot.postprocessing.similarity.on === "True",
cutoff: chatbot.postprocessing.similarity.cutoff,
},
colbert_rerank: {
on: chatbot.postprocessing.colbertRerank.on === "True",
top_n: chatbot.postprocessing.colbertRerank.top_n,
},
long_context_reorder: {
on: chatbot.postprocessing.longContextReorder.on === "True",
},
prompt: "",
};

return clientChatbot;
console.log(response.data);
return response.data;
}

export const chatbotService = {
Expand Down
9 changes: 6 additions & 3 deletions ui/src/services/knowledge-base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,20 @@ export type ServerKnowledgeBaseConfig = z.infer<

async function fetchKnowledgeBases() {
const response = await axios.get(`${baseUrl}/api/knowledge-bases`);
return knowledgeBasesSchema.parse(response.data);
console.log(response.data);
return response.data;
}

async function fetchKnowledgeBaseById(id: string) {
const response = await axios.get(`${baseUrl}/api/knowledge-base/${id}`);
return serverKnowledgeBaseConfigSchema.parse(response.data);
console.log(response.data);
return response.data;
}

async function createKnowledgeBase(config: ClientKnowledgeBaseConfig) {
const response = await axios.post(`${baseUrl}/api/knowledge-bases`, config);
return serverKnowledgeBaseConfigSchema.parse(response.data);
console.log(response.data);
return response.data;
}

async function uploadFile(id: string, file: File) {
Expand Down

0 comments on commit 635da1c

Please sign in to comment.