Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #886

Merged
merged 5 commits into from
Jul 27, 2023
Merged

fixes #886

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gui/pages/Content/Agents/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function Details({agentDetails, runCount, goals, instructions, ag
</div>
<div className={styles.agent_info_box}>
<div><Image width={15} height={15} src="/images/books.svg" alt="book-icon"/></div>
<div style={info_text}>knowledge name</div>
<div style={info_text}>{agentDetails?.knowledge_name || 'Not Found' }</div>
</div>
<div className={styles.agent_info_box}>
<div><Image width={15} height={15} src="/images/deployed_code.svg" alt="model-icon"/></div>
Expand All @@ -174,10 +174,10 @@ export default function Details({agentDetails, runCount, goals, instructions, ag
{/* <div><Image width={15} height={15} src="/images/cancel_presentation.svg" alt="exit-icon"/></div>*/}
{/* <div style={info_text}>{exit}</div>*/}
{/*</div>*/}
<div className={styles.agent_info_box}>
{/* <div className={styles.agent_info_box}>
<div><Image width={15} height={15} src="/images/overview.svg" alt="window-icon"/></div>
<div style={info_text}>{agentDetails?.memory_window || 0} milliseconds</div>
</div>
</div> */}
<div className={styles.agent_info_box}>
<div><Image width={15} height={15} src="/images/key.svg" alt="permission-type-icon"/></div>
<div style={info_text}>{agentDetails?.permission_type.replace(/\s*\([^)]*\)/g, '') || ''}</div>
Expand Down
4 changes: 4 additions & 0 deletions superagi/controllers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import json

from superagi.models.toolkit import Toolkit
from superagi.models.knowledges import Knowledges

from sqlalchemy import func
# from superagi.types.db import AgentOut, AgentIn
Expand Down Expand Up @@ -480,13 +481,16 @@ def get_agent_configuration(agent_id: int,
AgentExecution.agent_id == agent_id).scalar()
total_tokens = db.session.query(func.sum(AgentExecution.num_of_tokens)).filter(
AgentExecution.agent_id == agent_id).scalar()


# Construct the JSON response
response = {result.key: result.value for result in results}
knowledge = db.session.query(Knowledges).filter(Knowledges.id == response['knowledge']).first()
response = merge(response, {"name": agent.name, "description": agent.description,
# Query the AgentConfiguration table for the speci
"goal": eval(response["goal"]),
"instruction": eval(response.get("instruction", '[]')),
"knowledge_name": knowledge.name,
"calls": total_calls,
"tokens": total_tokens,
"constraints": eval(response.get("constraints")),
Expand Down
2 changes: 1 addition & 1 deletion superagi/controllers/knowledges.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def install_selected_knowledge(knowledge_name: str, vector_db_index_id: int, org
file_chunks = S3Helper().get_json_file(selected_knowledge_config["file_path"])
vector = Vectordbs.get_vector_db_from_id(db.session, vector_db_index.vector_db_id)
db_creds = VectordbConfigs.get_vector_db_config_from_db_id(db.session, vector.id)
upsert_data = VectorEmbeddingFactory.build_vector_storge(vector.db_type).get_vector_embeddings_from_chunks(file_chunks)
upsert_data = VectorEmbeddingFactory.build_vector_storage(vector.db_type, file_chunks).get_vector_embeddings_from_chunks()
try:
vector_db_storage = VectorFactory.build_vector_storage(vector.db_type, vector_db_index.name, **db_creds)
vector_db_storage.add_embeddings_to_vector_db(upsert_data)
Expand Down
4 changes: 2 additions & 2 deletions superagi/models/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def eval_agent_config(cls, key, value):

"""

if key in ["name", "description", "agent_type", "exit", "model", "permission_type", "LTM_DB", "resource_summary"]:
if key in ["name", "description", "agent_type", "exit", "model", "permission_type", "LTM_DB", "resource_summary", "knowledge"]:
return value
elif key in ["project_id", "memory_window", "max_iterations", "iteration_interval", "knowledge"]:
elif key in ["project_id", "memory_window", "max_iterations", "iteration_interval"]:
return int(value)
elif key in ["goal", "constraints", "instruction", "is_deleted"]:
return eval(value)
Expand Down
9 changes: 5 additions & 4 deletions superagi/vector_embeddings/vector_embedding_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class VectorEmbeddingFactory:

@classmethod
def build_vector_storge(cls, vector_store: VectorStoreType, chunk_json: Optional[dict] = None):
def build_vector_storage(cls, vector_store: VectorStoreType, chunk_json: Optional[dict] = None):
"""
Get the vector embeddings from final chunks.
Args:
Expand All @@ -18,14 +18,14 @@ def build_vector_storge(cls, vector_store: VectorStoreType, chunk_json: Optional
The vector storage object
"""
final_chunks = []
uuid = []
embeds = []
metadata = []
vector_store = VectorStoreType.get_vector_store_type(vector_store)
if chunk_json is not None:
for key in chunk_json.keys():
final_chunks.append(chunk_json[key])

uuid = []
embeds = []
metadata = []
for i in range(0, len(final_chunks)):
uuid.append(final_chunks[i]["id"])
embeds.append(final_chunks[i]["embeds"])
Expand All @@ -35,6 +35,7 @@ def build_vector_storge(cls, vector_store: VectorStoreType, chunk_json: Optional
'knowledge_name': final_chunks[i]['knowledge_name']
}
metadata.append(data)

if vector_store == VectorStoreType.PINECONE:
return Pinecone(uuid, embeds, metadata)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def test_build_vector_storge(self, mock_qdrant, mock_pinecone):
"2": {"id": 2, "embeds": [4,5,6], "text": "test2", "chunk": "chunk2", "knowledge_name": "knowledge2"},
}

vector_storge = VectorEmbeddingFactory.build_vector_storge('Pinecone', test_data)
vector_storge = VectorEmbeddingFactory.build_vector_storage('Pinecone', test_data)

mock_pinecone.assert_called_once_with(
[1,2], [[1,2,3],[4,5,6]], [{"text": "test", "chunk": "chunk", "knowledge_name": "knowledge"}, {"text": "test2", "chunk": "chunk2", "knowledge_name": "knowledge2"}]
)

vector_storge = VectorEmbeddingFactory.build_vector_storge('Qdrant', test_data)
vector_storge = VectorEmbeddingFactory.build_vector_storage('Qdrant', test_data)

mock_qdrant.assert_called_once_with(
[1,2], [[1,2,3],[4,5,6]], [{"text": "test", "chunk": "chunk", "knowledge_name": "knowledge"}, {"text": "test2", "chunk": "chunk2", "knowledge_name": "knowledge2"}]
Expand Down