Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
breadchris committed Feb 3, 2024
1 parent ee0132c commit 0e77277
Show file tree
Hide file tree
Showing 46 changed files with 2,982 additions and 6,609 deletions.
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ plugins:
out: swift/Generated
- plugin: buf.build/apple/swift
opt: Visibility=Public
out: mobile/lunabrain/Generated
out: swift/Generated
4 changes: 2 additions & 2 deletions js/dist/extension/background.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/dist/extension/background.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions js/dist/extension/content.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/dist/extension/content.js.map

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions js/dist/extension/options.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/dist/extension/options.js.map

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions js/dist/extension/tab.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/dist/extension/tab.js.map

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions js/dist/extension/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,45 @@ html {
--tw-backdrop-sepia: ;
}

.markdown h1 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}

.markdown h1 {
font-size: 1.5rem;
line-height: 2rem;
}

.markdown h2 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}

.markdown h2 {
font-size: 1.25rem;
line-height: 1.75rem;
}

.markdown h3 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}

.markdown h3 {
font-size: 1.125rem;
line-height: 1.75rem;
}

.markdown a {
--tw-text-opacity: 1;
color: rgb(37 99 235 / var(--tw-text-opacity));
text-decoration-line: underline;
}

.\!container {
width: 100% !important;
}
Expand Down
108 changes: 54 additions & 54 deletions js/dist/site/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions js/dist/site/index.js.map

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions js/dist/site/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,45 @@ html {
--tw-backdrop-sepia: ;
}

.markdown h1 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}

.markdown h1 {
font-size: 1.5rem;
line-height: 2rem;
}

.markdown h2 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}

.markdown h2 {
font-size: 1.25rem;
line-height: 1.75rem;
}

.markdown h3 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}

.markdown h3 {
font-size: 1.125rem;
line-height: 1.75rem;
}

.markdown a {
--tw-text-opacity: 1;
color: rgb(37 99 235 / var(--tw-text-opacity));
text-decoration-line: underline;
}

.\!container {
width: 100% !important;
}
Expand Down
46 changes: 42 additions & 4 deletions js/extension/background.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/// <reference types="chrome"/>
import {contentService, projectService, userService} from "@/service";
import {urlContent} from "./util";
import {contentGet, contentSave, TabContent} from "./shared";
import { Content } from "@/rpc/content/content_pb";
import HttpHeader = chrome.webRequest.HttpHeader;
import {Conversation} from "@/rpc/content/chatgpt/conversation_pb";
import {Conversation, ImageAsset, Content as ConvContent} from "@/rpc/content/chatgpt/conversation_pb";
import {Conversation as TSConversation} from "./chatgpt";

let tabContent: TabContent|undefined = undefined;
let history: {
Expand Down Expand Up @@ -168,11 +168,49 @@ const chromeExt = () => {
}).then((resp) => {
// TODO breadchris create content and send it to the content script
return resp.json();
}).then((json) => {
}).then((json: TSConversation) => {
console.log('json', json)
const conv = Conversation.fromJson(json, {
let conv = Conversation.fromJson(json as any, {
ignoreUnknownFields: true
});

Object.keys(json.mapping).map((k: any) => {
const v = json.mapping[k];
const c = v.message?.content;
if (!c) {
return;
}
let textParts: string[] = [];
let imageParts: ImageAsset[] = [];
let text = '';
switch (c.content_type) {
case 'text':
textParts = c.parts;
break;
case 'multimodal_text':
imageParts = c.parts.map((p) => {
return ImageAsset.fromJson(p as any, {
ignoreUnknownFields: true
});
});
break;
case 'code':
text = c.text;
break;
}
if (conv.mapping[k].message !== undefined) {
// @ts-ignore
conv.mapping[k].message.content = new ConvContent({
contentType: c.content_type as string,
textParts: textParts,
imageParts: imageParts,
text: text
});
}
});

console.log(conv)

const content = new Content({
id: conv.conversationId,
type: {
Expand Down
70 changes: 70 additions & 0 deletions js/extension/chatgpt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
export interface Conversation {
title: string;
create_time: number;
update_time: number;
mapping: { [key: string]: Node };
moderation_results: any[]; // Replace 'any' with a more specific type if available
current_node: string;
plugin_ids: null; // Replace 'null' with the actual type if it can be something other than null
conversation_id: string;
conversation_template_id: null; // Replace 'null' with the actual type if it can be something other than null
gizmo_id: null; // Replace 'null' with the actual type if it can be something other than null
is_archived: boolean;
safe_urls: any[]; // Replace 'any' with a more specific type if available
}

interface Node {
id: string;
message: Message | undefined;
parent: string | undefined;
children: string[];
}

interface Message {
id: string;
author: Author;
create_time: number | undefined;
update_time: number | undefined;
content: TextContent | CodeContent | MultimodalContent | undefined;
status: string;
end_turn: boolean | undefined;
weight: number;
metadata: Metadata;
recipient: string;
}

interface Author {
role: string;
name: string | undefined;
metadata: any; // Replace 'any' with a more specific type if available
}

interface CodeContent {
content_type: 'code';
language: string;
text: string;
}

interface TextContent {
content_type: 'text';
parts: string[];
}

interface MultimodalContent {
content_type: 'multimodal_text';
parts: ImageAsset[];
}

interface ImageAsset {
content_type: 'image_asset_pointer';
asset_pointer: string;
size_bytes: number;
width: number;
height: number;
fovea: number;
metadata: Metadata;
}

interface Metadata {
[key: string]: any;
}
Loading

0 comments on commit 0e77277

Please sign in to comment.