-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): chat the corpus + refactor schema (#57)
* workon schema * refactor schema serverside python * update rust client * genall finish
- Loading branch information
Showing
29 changed files
with
593 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#! /bin/bash | ||
set -e | ||
|
||
pushd py | ||
./genall.sh | ||
popd | ||
|
||
pushd rs | ||
./genall.sh | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import List | ||
from ninja import Schema | ||
|
||
|
||
class MessageSchema(Schema): | ||
role: str # e.g., "user", "system", "assistant" | ||
text: str | ||
|
||
|
||
class CorpusChatSchema(Schema): | ||
corpus_id: str | ||
messages: List[MessageSchema] | ||
# optional additional context: voice, purpose, structure, directions | ||
voice: str = "" | ||
purpose: str = "" | ||
structure: str = "" | ||
directions: str = "" | ||
|
||
|
||
class CorpusFileChatSchema(CorpusChatSchema): | ||
path: str | ||
|
||
|
||
def get_additional_context(payload: CorpusChatSchema, ext: str = "") -> str: | ||
# TODO: more automatically expandable implementation | ||
# without the ifs | ||
context = "" | ||
if any( | ||
[ | ||
payload.voice, | ||
payload.purpose, | ||
payload.structure, | ||
payload.directions, | ||
] | ||
): | ||
context += "\n\nADDITIONAL CONTEXT:\n\n" | ||
|
||
if payload.voice: | ||
context += f"VOICE:\n\n{payload.voice}\n\n" | ||
|
||
if payload.purpose: | ||
context += f"PURPOSE of corpus:\n\n{payload.purpose}\n\n" | ||
|
||
if payload.structure: | ||
context += f"STRUCTURE of corpus:\n\n{payload.structure}\n\n" | ||
|
||
if payload.directions: | ||
context += f"DIRECTIONS for {ext} filetype:\n\n{payload.directions}\n\n" | ||
|
||
return context |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.