Skip to content

Commit 7859075

Browse files
committed
it looks like we can now see reasoning going on!
1 parent 8a22b5c commit 7859075

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

src/components/taskyon/TaskChainViewer.vue

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@
5151
</q-tree>
5252
<template v-else>
5353
<template v-for="(task, idx) in props.selectedThread" :key="task.id">
54-
<q-expansion-item v-if="reasoning.get(task.id)" label="thoughts:" dense>
54+
<q-expansion-item
55+
v-if="reasoning.get(task.id)"
56+
label="reasoning"
57+
dense
58+
class="text-caption"
59+
>
5560
<tyMarkdown :src="reasoning.get(task.id)!" />
5661
</q-expansion-item>
5762
<Task
@@ -71,6 +76,19 @@
7176
</template>
7277
<!--Render tasks which are in progress-->
7378
<div class="task-logs q-py-sm">
79+
<tyMarkdown
80+
v-if="
81+
currentMessageStream?.length === 0 &&
82+
currentThinkingStream &&
83+
currentThinkingStream.length > 0
84+
"
85+
no-line-numbers
86+
no-mermaid
87+
:src="'THINKING:\n' + currentThinkingStream?.split('\n').slice(-20).join('\n')"
88+
class="text-caption"
89+
style="font-size: 0.8rem"
90+
>
91+
</tyMarkdown>
7492
<q-card
7593
v-if="
7694
!!tystate.lastTaskState.get(currentTask.id) &&
@@ -80,14 +98,10 @@
8098
flat
8199
>
82100
<div class="col">
83-
<tyMarkdown v-if="!currentMessageStream && currentThinkingStream">
84-
{{ currentThinkingStream?.slice(-200) }}
85-
</tyMarkdown>
86101
<tyMarkdown
87102
v-if="currentMessageStream"
88103
no-line-numbers
89104
no-mermaid
90-
:use-iframe="false"
91105
:src="currentMessageStream || ''"
92106
/>
93107
<div>
@@ -156,11 +170,12 @@ const props = defineProps<{
156170
157171
const reasoning = ref(new Map<string, string>())
158172
watch(
159-
props.selectedThread,
160-
(thread) => {
173+
() => props.currentTask.id,
174+
() => {
175+
console.log('re-calculate reason lists!')
161176
reasoning.value.clear()
162177
void Promise.all(
163-
thread.map(async (t) => {
178+
props.selectedThread.map(async (t) => {
164179
const meta = await tystate.getMeta(t.id)
165180
if (meta) {
166181
const reason = getReasoning(meta)
@@ -222,9 +237,9 @@ const currentMessageStream = computed(() => {
222237
})
223238
224239
const currentThinkingStream = computed(() => {
225-
if (props.currentTask)
240+
if (props.currentTask) {
226241
return streamingTracker.value.get(props.currentTask.id)?.choices?.[0]?.reasoning || ''
227-
else return undefined
242+
} else return undefined
228243
})
229244
230245
const currentFunctionStream = computed(() => {

src/css/markdown.sass

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ $primary: var(--q-primary-rgb)
8686
border-radius: 0.25rem
8787
cursor: pointer
8888
transition: background 0.2s ease
89-
z-index: 10
89+
//z-index: 10
9090
9191
&:hover
9292
background: rgba($secondary, 0.05)

src/modules/tools/chatCompletionTool.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,15 @@ export async function createChatCompletionTool(
799799
// parse the response into our own type ...
800800
const choice = chatCompletion?.choices[0]
801801

802-
let metaInfo: TaskNodeMeta = { taskPrompt: chatInfo, rawOutput: chatCompletion }
802+
let metaInfo: TaskNodeMeta = {
803+
taskPrompt: chatInfo,
804+
rawOutput: chatCompletion,
805+
}
803806
// get token usage for this task..
804807
if (currentTask && lastTaskBeforeChatCompletion) {
805808
if (chatCompletion) {
806809
console.log('save token usage...')
807-
// openai & openrouter sends back the exact number of prompt tokens :)
810+
// openai & openrouter sends back the exact number of prompt tokens :)
808811
metaInfo = {
809812
...metaInfo,
810813
...(await saveTokenUsage(
@@ -820,6 +823,7 @@ export async function createChatCompletionTool(
820823

821824
void addTaskCostInformation(chatCompletion, currentTask?.id, llmSettings, apiKeys).then(
822825
(newMeta) => {
826+
console.log('found new task costs:', newMeta)
823827
void taskManager.debugDb.upsert(currentTask.id, newMeta, 'shallow_merge')
824828
},
825829
)

0 commit comments

Comments
 (0)