Skip to content

Commit

Permalink
MERGE feature/76-updates-params-for-ability-to-fetch-from-other-prope…
Browse files Browse the repository at this point in the history
…rties INTO development (#77)

* MERGE development INTO master (#74)

* MERGE feature/50-adds-settings-and-updates-history-endpoints INTO development (#51)

* Endpoints reconfigurged for settings and history

* Update changelog

* MERGE Feature/rag chat fixed to not be agent INTO development (#53)

* Rag chat fixed

* Remove body from create for now, may change how this works later

* Works for saas, may stop workign on vercel

* MERGE feature/55-update-ollama-rag-chat INTO development (#56)

* Contains updates for ollama rag but is a bit more custom than intended, doesn't include return docs atm.

* Rag working for both openai and ollama

* MERGE feature/55-update-ollama-rag-chat INTO development (#57)

* Contains updates for ollama rag but is a bit more custom than intended, doesn't include return docs atm.

* Rag working for both openai and ollama

* Update changelog

* Update changlog

* fixing the retrieval routes

* Update changelog

* Update retrieval controller with file upload

* Adds better error handling for tools in agent

* Changes made (#62)

* MERGE feature/64-retricts-what-can-be-passed-to-settings-and-history INTO development (#65)

* Updates to restrict the keys that can be saved

* Adds the keys as args so could be altered

* adds some type hinting

* Small fix in history controller

* Need to account for tags and title on history and settings

* Switch to a set to be more efficient (#71)

* A couple adjustments

* Had to update the PINECONE_KEY to PINECONE_API_KEY

* Had to do some updates

* update HistoryController with user_id for webhook

* Update changelog

* Made, may need to take a second look edit mode is not working in the other repo

* Updates changelog
  • Loading branch information
ryaneggz authored Dec 31, 2023
1 parent ac4dc5d commit 0ac173d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
5 changes: 4 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.1.11
### Added
- feature/76-updates-params-for-ability-to-fetch-from-other-properties (2023-12-31)

## 1.1.10
### Added
- Updates HistoryController constructor to include a user_id as request alternative. (2023-12-30)
Expand Down Expand Up @@ -35,7 +39,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## 1.1.2
### Added

- feature/55-update-ollama-rag-chat (2023-12-17)

## 1.1.1
Expand Down
21 changes: 15 additions & 6 deletions promptengineers/fastapi/controllers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ def __init__(
##############################################################
### Create Chat History
##############################################################
async def index(self, page: int = 1, limit: int = 10):
result = await self.history_service.list_docs(
{'user_id': ObjectId(self.user_id)},
limit,
page
)
async def index(self, page: int = 1, limit: int = 10, **kwargs):
# Base query with user_id
query = {'user_id': ObjectId(self.user_id)}

# Add additional filters passed as keyword arguments
for key, value in kwargs.items():
if value is not None: # Ensure that a value is provided for the filter
# Convert to ObjectId if necessary, for example, if key ends with "_id"
if key in {'setting'}:
query[key] = ObjectId(value)
else:
query[key] = value

# Get the result from the history_service
result = await self.history_service.list_docs(query, limit, page)
return result

##############################################################
Expand Down
52 changes: 27 additions & 25 deletions promptengineers/fastapi/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,34 @@ def get_controller(request: Request) -> HistoryController:
response_model=ResponseHistoryIndex
)
async def list_chat_histories(
page: int = 1,
limit: int = 50,
controller: HistoryController = Depends(get_controller),
page: int = 1,
limit: int = 50,
setting: str = None,
controller: HistoryController = Depends(get_controller),
):
"""List histories"""
try:
result = await controller.index(page, limit)
# Format Response
data = json.dumps({
'histories': result
}, cls=JSONEncoder)
return Response(
content=data,
media_type='application/json',
status_code=200
)
except HTTPException as err:
logger.error(err.detail)
raise
except BaseException as err:
tb = traceback.format_exc()
logger.error("[list_chat_histories]: %s\n%s", err, tb)
raise HTTPException(
status_code=500,
detail=f"An unexpected error occurred. {str(err)}"
) from err
"""List histories"""
try:
# Forward the setting_id and any additional parameters to the controller's index method
result = await controller.index(page, limit, setting=setting)
# Format Response
data = json.dumps({
'histories': result
}, cls=JSONEncoder)
return Response(
content=data,
media_type='application/json',
status_code=200
)
except HTTPException as err:
logger.error(err.detail)
raise
except BaseException as err:
tb = traceback.format_exc()
logger.error("[list_chat_histories]: %s\n%s", err, tb)
raise HTTPException(
status_code=500,
detail=f"An unexpected error occurred. {str(err)}"
) from err

#################################################
# Create Chat History
Expand Down
2 changes: 1 addition & 1 deletion promptengineers/fastapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def show(

# Format Response
data = json.dumps({
**result
'setting': result
}, cls=JSONEncoder)
return Response(
content=data,
Expand Down

0 comments on commit 0ac173d

Please sign in to comment.