Skip to content

Commit

Permalink
Fix login (#312)
Browse files Browse the repository at this point in the history
* tmp dbg

* tmp dbg

* tmp dbg

* tmp dbg

* tmp dbg

* tmp dbg

* tmp dbg

* tmp dbg

* tmp dbgush

* tmp dbgush

* tmp dbgush

* tmp dbgush

* final fixes

* lint
  • Loading branch information
northdpole committed Jun 27, 2023
1 parent 8617461 commit 63580af
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
3 changes: 2 additions & 1 deletion application/frontend/src/pages/chatbot/chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ export const Chatbot = () => {
function displayDocument(d: Document) {
return (
<a href={d.hyperlink} target="_blank">
*Reference: The above answer was based on the {d.name} section of {d.section};
*Reference: The above answer was based on the {d.name} section of{' '}
{d.section ? d.section : d.sectionID};
</a>
);
}
Expand Down
15 changes: 9 additions & 6 deletions application/prompt_client/prompt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,7 @@ def __init__(self, database: db.Node_collection) -> None:
self.ai_client = None
if os.environ.get("SERVICE_ACCOUNT_CREDENTIALS"):
logger.info("using Google Vertex AI engine")
self.ai_client = vertex_prompt_client.VertexPromptClient(
os.environ.get("VERTEX_PROJECT_ID"),
os.environ.get("VERTEX_PROJECT_LOCATION"),
)
self.ai_client = vertex_prompt_client.VertexPromptClient()
elif os.getenv("OPENAI_API_KEY"):
logger.info("using Open AI engine")
self.ai_client = openai_prompt_client.OpenAIPromptClient(
Expand Down Expand Up @@ -433,10 +430,16 @@ def generate_text(self, prompt: str) -> Dict[str, str]:
logger.info(
f"The prompt {prompt}, was most similar to object \n{closest_object}\n, with similarity:{similarity}"
)
closest_content = ""
if closest_object.hyperlink:
emb = self.database.get_embedding(closest_id)
if emb:
closest_content = emb[0].embeddings_content
if closest_object:
closest_object_str = "\n".join(
closest_object_str = f"{closest_content}" + "\n".join(
[f"{k}:{v}" for k, v in closest_object.shallow_copy().todict().items()]
)[:8000]
)
closest_object_str = closest_object_str[:8000]
# vertex and openai have a model limit of 8100 characters
answer = self.ai_client.create_chat_completion(
prompt=prompt,
Expand Down
Loading

0 comments on commit 63580af

Please sign in to comment.