Skip to content

Commit

Permalink
merging with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
namansleeps committed Sep 15, 2023
2 parents a7aa396 + c96ae0e commit ab58735
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 36 deletions.
11 changes: 3 additions & 8 deletions gui/pages/Content/Agents/ActivityFeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat
const [scheduleTime, setScheduleTime] = useState(null);
const [isLoading, setIsLoading] = useState(true);
const [waitingPeriod, setWaitingPeriod] = useState(null);
const [waitingPeriodOver, setWaitingPeriodOver] = useState(null);
const [errorMsg, setErrorMsg] = useState('');

useEffect(() => {
const interval = window.setInterval(function () {
if (selectedRunStatus === "RUNNING") {
if (selectedRunStatus !== "ERROR_PAUSED") {
fetchFeeds();
}
}, 5000);
Expand Down Expand Up @@ -78,10 +77,6 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat
EventBus.emit('reFetchAgents', {});
}, [runStatus])

useEffect(() => {
setWaitingPeriodOver(updateDateBasedOnValue(convertWaitingPeriod(waitingPeriod)))
}, [waitingPeriod]);

function fetchFeeds() {
if (selectedRunId !== null) {
setIsLoading(true);
Expand Down Expand Up @@ -157,7 +152,7 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat
<div className="history_box padding_20 cursor_default bg_secondary">
<div style={{display: 'flex'}}>
<div className="fs_20 lh_24"></div>
<div className={styles.feed_title}>Waiting Block Initiated. The Agent will wait for {convertWaitingPeriod(waitingPeriod) || null} and continue on {waitingPeriodOver || 'soon'}</div>
<div className={styles.feed_title}>Waiting Block Initiated. The Agent will wait for {convertWaitingPeriod(waitingPeriod) || null}</div>
</div>
</div>}
{runStatus === 'RUNNING' &&
Expand Down Expand Up @@ -185,7 +180,7 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat
<div className="history_box padding_20 cursor_default bg_secondary">
<div style={{display: 'flex'}}>
<div className="fs_20"></div>
<div className={styles.feed_title}>{parseTextWithLinks(errorMsg)}</div>
<div className={styles.feed_title}>{errorMsg}</div>
</div>
</div>}
</div>
Expand Down
41 changes: 20 additions & 21 deletions gui/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {baseUrl} from "@/pages/api/apiConfig";
import {EventBus} from "@/utils/eventBus";
import JSZip from "jszip";
import moment from 'moment';
import {useRouter} from "next/router";

const toolkitData = {
'Jira Toolkit': '/images/jira_icon.svg',
Expand Down Expand Up @@ -524,26 +523,26 @@ export const convertWaitingPeriod = (waitingPeriod) => {
return convertedValue + ' ' + unit;
}

export const updateDateBasedOnValue = (convertedValue, inputDate = new Date()) => {
const [value, unit] = convertedValue.split(' ');
const unitConversion = {
'seconds': 1000,
'minutes': 1000 * 60,
'hours': 1000 * 60 * 60,
'days': 1000 * 60 * 60 * 24,
'weeks': 1000 * 60 * 60 * 24 * 7
};

const updatedDate = new Date(inputDate.getTime() + parseInt(value, 10) * unitConversion[unit]);

return updatedDate.toLocaleString('en-US', {
day: 'numeric',
month: 'long',
year: 'numeric',
hour: 'numeric',
minute: 'numeric'
});
}
// export const updateDateBasedOnValue = (convertedValue, inputDate = new Date()) => {
// const [value, unit] = convertedValue.split(' ');
// const unitConversion = {
// 'seconds': 1000,
// 'minutes': 1000 * 60,
// 'hours': 1000 * 60 * 60,
// 'days': 1000 * 60 * 60 * 24,
// 'weeks': 1000 * 60 * 60 * 24 * 7
// };
//
// const updatedDate = new Date(inputDate.getTime() + parseInt(value, 10) * unitConversion[unit]);
//
// return updatedDate.toLocaleString('en-US', {
// day: 'numeric',
// month: 'long',
// year: 'numeric',
// hour: 'numeric',
// minute: 'numeric'
// });
// }

export const getUTMParametersFromURL = () => {
const params = new URLSearchParams(window.location.search);
Expand Down
3 changes: 2 additions & 1 deletion superagi/agent/agent_iteration_step_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def execute_step(self):
print("Decoding JSON has failed")
tool_name = ''

CallLogHelper(session=self.session, organisation_id=organisation.id).create_call_log(execution.name,agent_config['agent_id'],total_tokens, tool_name,agent_config['model'])
CallLogHelper(session=self.session, organisation_id=organisation.id).create_call_log(execution.name,
agent_config['agent_id'], total_tokens, tool_name, agent_config['model'])

assistant_reply = response['content']
output_handler = get_output_handler(iteration_workflow_step.output_type,
Expand Down
5 changes: 2 additions & 3 deletions superagi/helper/validate_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ def correct_csv_encoding(file_path):
if encoding != 'utf-8':
data = []
with open(file_path, 'r', encoding=encoding) as f:
reader = csv.reader(f, delimiter=';', quotechar='"')
reader = csv.reader(f, delimiter=',', quotechar='"')
for row in reader:
try:
data.append(row)
except Exception as e:
logger.error(f"An error occurred while processing the file: {e}")
continue

df = pd.DataFrame(data)

df = pd.DataFrame(data[1:], columns=data[0])
df.to_csv(file_path, encoding='utf-8', index=False)
logger.info("File is converted to utf-8 encoding.")
else:
Expand Down
2 changes: 0 additions & 2 deletions superagi/tools/file/read_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ def _execute(self, file_name: str):

content = "\n".join(content)
else:
logger.info(final_path)
if final_path.endswith('.csv'):
correct_csv_encoding(final_path)
elements = partition(final_path)
logger.info(elements)
content = "\n\n".join([str(el) for el in elements])

if temporary_file_path is not None:
Expand Down
2 changes: 1 addition & 1 deletion superagi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def summarize_resource(agent_id: int, resource_id: int):
documents = ResourceManager(str(agent_id)).create_llama_document(file_path)

logger.info("Summarize resource:" + str(agent_id) + "," + str(resource_id))
resource_summarizer = ResourceSummarizer(session=session, agent_id=agent_id)
resource_summarizer = ResourceSummarizer(session=session, agent_id=agent_id, model=agent_config["model"])
resource_summarizer.add_to_vector_store_and_create_summary(resource_id=resource_id,
documents=documents)
session.close()
Expand Down

0 comments on commit ab58735

Please sign in to comment.