Origin of Ray

Lift the fog of the Internet together

Recently, I was using python to call the sse interface of gpt and return it to my front end through sse. I encountered a few problems, and I simply recorded them. There was no amount of code, but it took me more than half a day to get it done.

  • how to return sse in python
  • why do the newlines in the sse I return always get lost
Read more »

We all know that the interface of ChatGPT supports data return by streaming SSE, and the front-end browser provides EventSource by default to receive SSE, but the problem is that the default EventSource only supports Get requests, and does not support any custom headers. The interface of ChatGPT is a POST request, and it is necessary to carry a token in the header, so a Microsoft library is used. Let’s explain its usage, source code, and the basis for its source code to run from a protocol perspective, that is, why its source code can work

Read more »

Recently, I was curious about the protocol that chatgpt can return with streaming requests, so I went to learn about it. At first, I thought it was HTTP2, or the WS protocol, but later found out that it was not, but a protocol called SSE (Server-Sent Events).) protocol.

Read more »

Before, I made a request for a relational graph. Because exporting png and other images will be distorted when enlarged, I hope to export them as vector graphs. However, the export graph function that comes with G6 cannot be exported as SVG in Canvas mode, and SVG mode has many features that are not supported, so I tried to find a way to export Canvas as SVG.

Read more »

Greedy algorithm is a relatively common algorithm. The essence of greed is to choose the local optimal of each stage to achieve the global optimal. Simulated annealing algorithms are more common in artificial intelligence.

The reason why these two algorithms are considered together is that the simulated annealing algorithm is like an enhanced version of the greedy algorithm.

If the local optimal solution of each step of a problem cannot obtain the global optimal solution, the algorithm thinking of our conventional front-end and back-end programmers is Dynamic Programming.

But for AI development, the parameters may be hundreds of millions of levels, there is no way Dynamic Programming, this time you can try to use simulated annealing algorithm to jump out of this part with a certain probability, to find a better answer in the whole, but in fact This algorithm is not like a conventional algorithm, and will get an inevitable result.

This article summarizes and compares the two algorithms together to see where they are applicable and how to use them.

Read more »

Tailwind this CSS framework is not something new, but has not been to study, recently there is a need to look at it, it looks relatively simple.

This thing looks like a new DSL or something, providing many commonly used and built-in CSS styles, encapsulating them into syntax, and then providing a PostCSS plugin to process the encapsulated syntax back into ordinary CSS.

All we need to do is install Tailwind’s PostCSS plugin and use his encapsulated DSL.

Read more »

Recently, I was thinking about how to implement the relationship diagram of Feishu Docs, so I remembered the G6 I used before, so I simply implemented a version.

Final effect

The main functions are as follows:

  • The node is divided into two parts, the top half is the icon and the bottom half is the text
    • When the mouse is placed on the icon, it will produce a diffusion effect of water ripples, and a circle of borders will appear at the same time
    • Text needs to be underlined and have a white background, and the water ripple effect cannot be blocked by the white background
    • The underline of the text needs to be a square
  • The connection should have a gradual change of color, and the gradual change of color should be from the beginning of the arrow to the end of the arrow, and if the two-way relationship is supported, how to achieve two edges
  • There should be a Label in the middle of the connection
  • Nodes and connections should support translucency
  • The overall layout should be a force-oriented layout, and node dragging is supported. When dragging, nodes cannot overlap, but other nodes cannot be dragged due to connection (this point is raised separately because G6’s built-in force-oriented layout nodes will be dragged).
Read more »

As a programmer, we usually focus on management knowledge, initially may be Design pattern, management is the complexity of a certain requirement, slowly, we will begin to pay attention to domain division, DDD, business modeling, etc., these management is the complexity of the system, and then later, the complexity of things gradually evolved to our personal can not handle, we need teamwork, here is the management of project complexity.

In fact, these three will exist and are interrelated from beginning to end, and many concepts are similar, but we need to gradually participate in the actual work to realize this complexity step by step.

Regarding Design pattern and domain-driven design, my previous blogs have summarized some of the books and specific practices I have read. This time, combined with my personal experience and the book “Knowledge and Action”, I will summarize some methodologies in project management…

Read more »

Recently, I need to implement a relational graph in my work. The node layout in the graph needs to use force-oriented layout, so I was interested in the force-oriented algorithm involved, and I went to study it.

Force-directed graph drawings can be used to describe the relationships between nodes of a graph, distributing nodes to reasonable positions on the canvas, such as describing relationships between enterprises, interpersonal relationships in social networks, etc.

Read more »
0%